| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 var wp; 2 (wp ||= {}).customizeWidgets = (() => { 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 name in all) 14 __defProp(target, name, { get: all[name], 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/element 35 var require_element = __commonJS({ 36 "package-external:@wordpress/element"(exports, module) { 37 module.exports = window.wp.element; 38 } 39 }); 40 41 // package-external:@wordpress/block-library 42 var require_block_library = __commonJS({ 43 "package-external:@wordpress/block-library"(exports, module) { 44 module.exports = window.wp.blockLibrary; 45 } 46 }); 47 48 // package-external:@wordpress/widgets 49 var require_widgets = __commonJS({ 50 "package-external:@wordpress/widgets"(exports, module) { 51 module.exports = window.wp.widgets; 52 } 53 }); 54 55 // package-external:@wordpress/blocks 56 var require_blocks = __commonJS({ 57 "package-external:@wordpress/blocks"(exports, module) { 58 module.exports = window.wp.blocks; 59 } 60 }); 61 62 // package-external:@wordpress/data 63 var require_data = __commonJS({ 64 "package-external:@wordpress/data"(exports, module) { 65 module.exports = window.wp.data; 66 } 67 }); 68 69 // package-external:@wordpress/preferences 70 var require_preferences = __commonJS({ 71 "package-external:@wordpress/preferences"(exports, module) { 72 module.exports = window.wp.preferences; 73 } 74 }); 75 76 // package-external:@wordpress/components 77 var require_components = __commonJS({ 78 "package-external:@wordpress/components"(exports, module) { 79 module.exports = window.wp.components; 80 } 81 }); 82 83 // package-external:@wordpress/i18n 84 var require_i18n = __commonJS({ 85 "package-external:@wordpress/i18n"(exports, module) { 86 module.exports = window.wp.i18n; 87 } 88 }); 89 90 // package-external:@wordpress/block-editor 91 var require_block_editor = __commonJS({ 92 "package-external:@wordpress/block-editor"(exports, module) { 93 module.exports = window.wp.blockEditor; 94 } 95 }); 96 97 // package-external:@wordpress/compose 98 var require_compose = __commonJS({ 99 "package-external:@wordpress/compose"(exports, module) { 100 module.exports = window.wp.compose; 101 } 102 }); 103 104 // package-external:@wordpress/hooks 105 var require_hooks = __commonJS({ 106 "package-external:@wordpress/hooks"(exports, module) { 107 module.exports = window.wp.hooks; 108 } 109 }); 110 111 // vendor-external:react/jsx-runtime 112 var require_jsx_runtime = __commonJS({ 113 "vendor-external:react/jsx-runtime"(exports, module) { 114 module.exports = window.ReactJSXRuntime; 115 } 116 }); 117 118 // package-external:@wordpress/core-data 119 var require_core_data = __commonJS({ 120 "package-external:@wordpress/core-data"(exports, module) { 121 module.exports = window.wp.coreData; 122 } 123 }); 124 125 // package-external:@wordpress/media-utils 126 var require_media_utils = __commonJS({ 127 "package-external:@wordpress/media-utils"(exports, module) { 128 module.exports = window.wp.mediaUtils; 129 } 130 }); 131 132 // package-external:@wordpress/keycodes 133 var require_keycodes = __commonJS({ 134 "package-external:@wordpress/keycodes"(exports, module) { 135 module.exports = window.wp.keycodes; 136 } 137 }); 138 139 // package-external:@wordpress/primitives 140 var require_primitives = __commonJS({ 141 "package-external:@wordpress/primitives"(exports, module) { 142 module.exports = window.wp.primitives; 143 } 144 }); 145 146 // package-external:@wordpress/keyboard-shortcuts 147 var require_keyboard_shortcuts = __commonJS({ 148 "package-external:@wordpress/keyboard-shortcuts"(exports, module) { 149 module.exports = window.wp.keyboardShortcuts; 150 } 151 }); 152 153 // node_modules/fast-deep-equal/es6/index.js 154 var require_es6 = __commonJS({ 155 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 156 "use strict"; 157 module.exports = function equal(a, b) { 158 if (a === b) return true; 159 if (a && b && typeof a == "object" && typeof b == "object") { 160 if (a.constructor !== b.constructor) return false; 161 var length, i, keys; 162 if (Array.isArray(a)) { 163 length = a.length; 164 if (length != b.length) return false; 165 for (i = length; i-- !== 0; ) 166 if (!equal(a[i], b[i])) return false; 167 return true; 168 } 169 if (a instanceof Map && b instanceof Map) { 170 if (a.size !== b.size) return false; 171 for (i of a.entries()) 172 if (!b.has(i[0])) return false; 173 for (i of a.entries()) 174 if (!equal(i[1], b.get(i[0]))) return false; 175 return true; 176 } 177 if (a instanceof Set && b instanceof Set) { 178 if (a.size !== b.size) return false; 179 for (i of a.entries()) 180 if (!b.has(i[0])) return false; 181 return true; 182 } 183 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { 184 length = a.length; 185 if (length != b.length) return false; 186 for (i = length; i-- !== 0; ) 187 if (a[i] !== b[i]) return false; 188 return true; 189 } 190 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; 191 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); 192 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); 193 keys = Object.keys(a); 194 length = keys.length; 195 if (length !== Object.keys(b).length) return false; 196 for (i = length; i-- !== 0; ) 197 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; 198 for (i = length; i-- !== 0; ) { 199 var key = keys[i]; 200 if (!equal(a[key], b[key])) return false; 201 } 202 return true; 203 } 204 return a !== a && b !== b; 205 }; 206 } 207 }); 208 209 // package-external:@wordpress/is-shallow-equal 210 var require_is_shallow_equal = __commonJS({ 211 "package-external:@wordpress/is-shallow-equal"(exports, module) { 212 module.exports = window.wp.isShallowEqual; 213 } 214 }); 215 216 // package-external:@wordpress/private-apis 217 var require_private_apis = __commonJS({ 218 "package-external:@wordpress/private-apis"(exports, module) { 219 module.exports = window.wp.privateApis; 220 } 221 }); 222 223 // package-external:@wordpress/dom 224 var require_dom = __commonJS({ 225 "package-external:@wordpress/dom"(exports, module) { 226 module.exports = window.wp.dom; 227 } 228 }); 229 230 // packages/customize-widgets/build-module/index.js 231 var index_exports = {}; 232 __export(index_exports, { 233 initialize: () => initialize, 234 store: () => store 235 }); 236 var import_element17 = __toESM(require_element()); 237 var import_block_library2 = __toESM(require_block_library()); 238 var import_widgets5 = __toESM(require_widgets()); 239 var import_blocks2 = __toESM(require_blocks()); 240 var import_data17 = __toESM(require_data()); 241 var import_preferences4 = __toESM(require_preferences()); 242 243 // packages/customize-widgets/build-module/components/customize-widgets/index.js 244 var import_element16 = __toESM(require_element()); 245 var import_components8 = __toESM(require_components()); 246 247 // packages/customize-widgets/build-module/components/error-boundary/index.js 248 var import_element = __toESM(require_element()); 249 var import_i18n = __toESM(require_i18n()); 250 var import_components = __toESM(require_components()); 251 var import_block_editor = __toESM(require_block_editor()); 252 var import_compose = __toESM(require_compose()); 253 var import_hooks = __toESM(require_hooks()); 254 var import_jsx_runtime = __toESM(require_jsx_runtime()); 255 function CopyButton({ text, children }) { 256 const ref = (0, import_compose.useCopyToClipboard)(text); 257 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, { size: "compact", variant: "secondary", ref, children }); 258 } 259 var ErrorBoundary = class extends import_element.Component { 260 constructor() { 261 super(...arguments); 262 this.state = { 263 error: null 264 }; 265 } 266 componentDidCatch(error) { 267 this.setState({ error }); 268 (0, import_hooks.doAction)("editor.ErrorBoundary.errorLogged", error); 269 } 270 render() { 271 const { error } = this.state; 272 if (!error) { 273 return this.props.children; 274 } 275 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( 276 import_block_editor.Warning, 277 { 278 className: "customize-widgets-error-boundary", 279 actions: [ 280 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyButton, { text: error.stack, children: (0, import_i18n.__)("Copy Error") }, "copy-error") 281 ], 282 children: (0, import_i18n.__)("The editor has encountered an unexpected error.") 283 } 284 ); 285 } 286 }; 287 288 // packages/customize-widgets/build-module/components/sidebar-block-editor/index.js 289 var import_compose3 = __toESM(require_compose()); 290 var import_core_data = __toESM(require_core_data()); 291 var import_data12 = __toESM(require_data()); 292 var import_element13 = __toESM(require_element()); 293 var import_block_editor8 = __toESM(require_block_editor()); 294 var import_media_utils = __toESM(require_media_utils()); 295 var import_preferences3 = __toESM(require_preferences()); 296 var import_block_library = __toESM(require_block_library()); 297 298 // packages/customize-widgets/build-module/components/block-inspector-button/index.js 299 var import_element2 = __toESM(require_element()); 300 var import_i18n2 = __toESM(require_i18n()); 301 var import_components2 = __toESM(require_components()); 302 var import_data = __toESM(require_data()); 303 var import_block_editor2 = __toESM(require_block_editor()); 304 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 305 function BlockInspectorButton({ inspector, closeMenu, ...props }) { 306 const selectedBlockClientId = (0, import_data.useSelect)( 307 (select) => select(import_block_editor2.store).getSelectedBlockClientId(), 308 [] 309 ); 310 const selectedBlock = (0, import_element2.useMemo)( 311 () => document.getElementById(`block-$selectedBlockClientId}`), 312 [selectedBlockClientId] 313 ); 314 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 315 import_components2.MenuItem, 316 { 317 onClick: () => { 318 inspector.open({ 319 returnFocusWhenClose: selectedBlock 320 }); 321 closeMenu(); 322 }, 323 ...props, 324 children: (0, import_i18n2.__)("Show more settings") 325 } 326 ); 327 } 328 var block_inspector_button_default = BlockInspectorButton; 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/customize-widgets/build-module/components/header/index.js 347 var import_components6 = __toESM(require_components()); 348 var import_block_editor4 = __toESM(require_block_editor()); 349 var import_element6 = __toESM(require_element()); 350 var import_keycodes3 = __toESM(require_keycodes()); 351 var import_i18n7 = __toESM(require_i18n()); 352 353 // packages/icons/build-module/library/close-small.js 354 var import_primitives = __toESM(require_primitives()); 355 var import_jsx_runtime3 = __toESM(require_jsx_runtime()); 356 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives.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" }) }); 357 358 // packages/icons/build-module/library/external.js 359 var import_primitives2 = __toESM(require_primitives()); 360 var import_jsx_runtime4 = __toESM(require_jsx_runtime()); 361 var external_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives2.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" }) }); 362 363 // packages/icons/build-module/library/more-vertical.js 364 var import_primitives3 = __toESM(require_primitives()); 365 var import_jsx_runtime5 = __toESM(require_jsx_runtime()); 366 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives3.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 367 368 // packages/icons/build-module/library/plus.js 369 var import_primitives4 = __toESM(require_primitives()); 370 var import_jsx_runtime6 = __toESM(require_jsx_runtime()); 371 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives4.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) }); 372 373 // packages/icons/build-module/library/redo.js 374 var import_primitives5 = __toESM(require_primitives()); 375 var import_jsx_runtime7 = __toESM(require_jsx_runtime()); 376 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives5.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" }) }); 377 378 // packages/icons/build-module/library/undo.js 379 var import_primitives6 = __toESM(require_primitives()); 380 var import_jsx_runtime8 = __toESM(require_jsx_runtime()); 381 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives6.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" }) }); 382 383 // packages/customize-widgets/build-module/components/inserter/index.js 384 var import_i18n3 = __toESM(require_i18n()); 385 var import_block_editor3 = __toESM(require_block_editor()); 386 var import_components3 = __toESM(require_components()); 387 var import_compose2 = __toESM(require_compose()); 388 var import_data4 = __toESM(require_data()); 389 390 // packages/customize-widgets/build-module/store/index.js 391 var import_data3 = __toESM(require_data()); 392 393 // packages/customize-widgets/build-module/store/reducer.js 394 var import_data2 = __toESM(require_data()); 395 function blockInserterPanel(state = false, action) { 396 switch (action.type) { 397 case "SET_IS_INSERTER_OPENED": 398 return action.value; 399 } 400 return state; 401 } 402 var reducer_default = (0, import_data2.combineReducers)({ 403 blockInserterPanel 404 }); 405 406 // packages/customize-widgets/build-module/store/selectors.js 407 var selectors_exports = {}; 408 __export(selectors_exports, { 409 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint, 410 isInserterOpened: () => isInserterOpened 411 }); 412 var EMPTY_INSERTION_POINT = { 413 rootClientId: void 0, 414 insertionIndex: void 0 415 }; 416 function isInserterOpened(state) { 417 return !!state.blockInserterPanel; 418 } 419 function __experimentalGetInsertionPoint(state) { 420 if (typeof state.blockInserterPanel === "boolean") { 421 return EMPTY_INSERTION_POINT; 422 } 423 return state.blockInserterPanel; 424 } 425 426 // packages/customize-widgets/build-module/store/actions.js 427 var actions_exports = {}; 428 __export(actions_exports, { 429 setIsInserterOpened: () => setIsInserterOpened 430 }); 431 function setIsInserterOpened(value) { 432 return { 433 type: "SET_IS_INSERTER_OPENED", 434 value 435 }; 436 } 437 438 // packages/customize-widgets/build-module/store/constants.js 439 var STORE_NAME = "core/customize-widgets"; 440 441 // packages/customize-widgets/build-module/store/index.js 442 var storeConfig = { 443 reducer: reducer_default, 444 selectors: selectors_exports, 445 actions: actions_exports 446 }; 447 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig); 448 (0, import_data3.register)(store); 449 450 // packages/customize-widgets/build-module/components/inserter/index.js 451 var import_jsx_runtime9 = __toESM(require_jsx_runtime()); 452 function Inserter({ setIsOpened }) { 453 const inserterTitleId = (0, import_compose2.useInstanceId)( 454 Inserter, 455 "customize-widget-layout__inserter-panel-title" 456 ); 457 const insertionPoint = (0, import_data4.useSelect)( 458 (select) => select(store).__experimentalGetInsertionPoint(), 459 [] 460 ); 461 return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)( 462 "div", 463 { 464 className: "customize-widgets-layout__inserter-panel", 465 "aria-labelledby": inserterTitleId, 466 children: [ 467 /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "customize-widgets-layout__inserter-panel-header", children: [ 468 /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( 469 "h2", 470 { 471 id: inserterTitleId, 472 className: "customize-widgets-layout__inserter-panel-header-title", 473 children: (0, import_i18n3.__)("Add a block") 474 } 475 ), 476 /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( 477 import_components3.Button, 478 { 479 size: "small", 480 icon: close_small_default, 481 onClick: () => setIsOpened(false), 482 "aria-label": (0, import_i18n3.__)("Close inserter") 483 } 484 ) 485 ] }), 486 /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "customize-widgets-layout__inserter-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( 487 import_block_editor3.__experimentalLibrary, 488 { 489 rootClientId: insertionPoint.rootClientId, 490 __experimentalInsertionIndex: insertionPoint.insertionIndex, 491 showInserterHelpPanel: true, 492 onSelect: () => setIsOpened(false) 493 } 494 ) }) 495 ] 496 } 497 ); 498 } 499 var inserter_default = Inserter; 500 501 // packages/customize-widgets/build-module/components/more-menu/index.js 502 var import_components5 = __toESM(require_components()); 503 var import_element5 = __toESM(require_element()); 504 var import_i18n6 = __toESM(require_i18n()); 505 var import_keycodes2 = __toESM(require_keycodes()); 506 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts()); 507 var import_preferences = __toESM(require_preferences()); 508 509 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/index.js 510 var import_components4 = __toESM(require_components()); 511 var import_i18n5 = __toESM(require_i18n()); 512 var import_keyboard_shortcuts2 = __toESM(require_keyboard_shortcuts()); 513 var import_data6 = __toESM(require_data()); 514 var import_element4 = __toESM(require_element()); 515 516 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/config.js 517 var import_i18n4 = __toESM(require_i18n()); 518 var textFormattingShortcuts = [ 519 { 520 keyCombination: { modifier: "primary", character: "b" }, 521 description: (0, import_i18n4.__)("Make the selected text bold.") 522 }, 523 { 524 keyCombination: { modifier: "primary", character: "i" }, 525 description: (0, import_i18n4.__)("Make the selected text italic.") 526 }, 527 { 528 keyCombination: { modifier: "primary", character: "k" }, 529 description: (0, import_i18n4.__)("Convert the selected text into a link.") 530 }, 531 { 532 keyCombination: { modifier: "primaryShift", character: "k" }, 533 description: (0, import_i18n4.__)("Remove a link.") 534 }, 535 { 536 keyCombination: { character: "[[" }, 537 description: (0, import_i18n4.__)("Insert a link to a post or page.") 538 }, 539 { 540 keyCombination: { modifier: "primary", character: "u" }, 541 description: (0, import_i18n4.__)("Underline the selected text.") 542 }, 543 { 544 keyCombination: { modifier: "access", character: "d" }, 545 description: (0, import_i18n4.__)("Strikethrough the selected text.") 546 }, 547 { 548 keyCombination: { modifier: "access", character: "x" }, 549 description: (0, import_i18n4.__)("Make the selected text inline code.") 550 }, 551 { 552 keyCombination: { 553 modifier: "access", 554 character: "0" 555 }, 556 aliases: [ 557 { 558 modifier: "access", 559 character: "7" 560 } 561 ], 562 description: (0, import_i18n4.__)("Convert the current heading to a paragraph.") 563 }, 564 { 565 keyCombination: { modifier: "access", character: "1-6" }, 566 description: (0, import_i18n4.__)( 567 "Convert the current paragraph or heading to a heading of level 1 to 6." 568 ) 569 }, 570 { 571 keyCombination: { modifier: "primaryShift", character: "SPACE" }, 572 description: (0, import_i18n4.__)("Add non breaking space.") 573 } 574 ]; 575 576 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.js 577 var import_element3 = __toESM(require_element()); 578 var import_keycodes = __toESM(require_keycodes()); 579 var import_jsx_runtime10 = __toESM(require_jsx_runtime()); 580 function KeyCombination({ keyCombination, forceAriaLabel }) { 581 const shortcut = keyCombination.modifier ? import_keycodes.displayShortcutList[keyCombination.modifier]( 582 keyCombination.character 583 ) : keyCombination.character; 584 const ariaLabel = keyCombination.modifier ? import_keycodes.shortcutAriaLabel[keyCombination.modifier]( 585 keyCombination.character 586 ) : keyCombination.character; 587 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( 588 "kbd", 589 { 590 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination", 591 "aria-label": forceAriaLabel || ariaLabel, 592 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map( 593 (character, index) => { 594 if (character === "+") { 595 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_element3.Fragment, { children: character }, index); 596 } 597 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( 598 "kbd", 599 { 600 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key", 601 children: character 602 }, 603 index 604 ); 605 } 606 ) 607 } 608 ); 609 } 610 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) { 611 return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [ 612 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-description", children: description }), 613 /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-term", children: [ 614 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( 615 KeyCombination, 616 { 617 keyCombination, 618 forceAriaLabel: ariaLabel 619 } 620 ), 621 aliases.map((alias, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( 622 KeyCombination, 623 { 624 keyCombination: alias, 625 forceAriaLabel: ariaLabel 626 }, 627 index 628 )) 629 ] }) 630 ] }); 631 } 632 var shortcut_default = Shortcut; 633 634 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js 635 var import_data5 = __toESM(require_data()); 636 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts()); 637 var import_jsx_runtime11 = __toESM(require_jsx_runtime()); 638 function DynamicShortcut({ name }) { 639 const { keyCombination, description, aliases } = (0, import_data5.useSelect)( 640 (select) => { 641 const { 642 getShortcutKeyCombination, 643 getShortcutDescription, 644 getShortcutAliases 645 } = select(import_keyboard_shortcuts.store); 646 return { 647 keyCombination: getShortcutKeyCombination(name), 648 aliases: getShortcutAliases(name), 649 description: getShortcutDescription(name) 650 }; 651 }, 652 [name] 653 ); 654 if (!keyCombination) { 655 return null; 656 } 657 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( 658 shortcut_default, 659 { 660 keyCombination, 661 description, 662 aliases 663 } 664 ); 665 } 666 var dynamic_shortcut_default = DynamicShortcut; 667 668 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/index.js 669 var import_jsx_runtime12 = __toESM(require_jsx_runtime()); 670 var ShortcutList = ({ shortcuts }) => ( 671 /* 672 * Disable reason: The `list` ARIA role is redundant but 673 * Safari+VoiceOver won't announce the list otherwise. 674 */ 675 /* eslint-disable jsx-a11y/no-redundant-roles */ 676 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 677 "ul", 678 { 679 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-list", 680 role: "list", 681 children: shortcuts.map((shortcut, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 682 "li", 683 { 684 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut", 685 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(shortcut_default, { ...shortcut }) 686 }, 687 index 688 )) 689 } 690 ) 691 ); 692 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)( 693 "section", 694 { 695 className: clsx_default( 696 "customize-widgets-keyboard-shortcut-help-modal__section", 697 className 698 ), 699 children: [ 700 !!title && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "customize-widgets-keyboard-shortcut-help-modal__section-title", children: title }), 701 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ShortcutList, { shortcuts }) 702 ] 703 } 704 ); 705 var ShortcutCategorySection = ({ 706 title, 707 categoryName, 708 additionalShortcuts = [] 709 }) => { 710 const categoryShortcuts = (0, import_data6.useSelect)( 711 (select) => { 712 return select(import_keyboard_shortcuts2.store).getCategoryShortcuts( 713 categoryName 714 ); 715 }, 716 [categoryName] 717 ); 718 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 719 ShortcutSection, 720 { 721 title, 722 shortcuts: categoryShortcuts.concat(additionalShortcuts) 723 } 724 ); 725 }; 726 function KeyboardShortcutHelpModal({ 727 isModalActive, 728 toggleModal 729 }) { 730 const { registerShortcut } = (0, import_data6.useDispatch)(import_keyboard_shortcuts2.store); 731 (0, import_element4.useEffect)(() => { 732 registerShortcut({ 733 name: "core/customize-widgets/keyboard-shortcuts", 734 category: "main", 735 description: (0, import_i18n5.__)("Display these keyboard shortcuts."), 736 keyCombination: { 737 modifier: "access", 738 character: "h" 739 } 740 }); 741 }, [registerShortcut]); 742 (0, import_keyboard_shortcuts2.useShortcut)("core/customize-widgets/keyboard-shortcuts", toggleModal); 743 if (!isModalActive) { 744 return null; 745 } 746 return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)( 747 import_components4.Modal, 748 { 749 className: "customize-widgets-keyboard-shortcut-help-modal", 750 title: (0, import_i18n5.__)("Keyboard shortcuts"), 751 onRequestClose: toggleModal, 752 children: [ 753 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 754 ShortcutSection, 755 { 756 className: "customize-widgets-keyboard-shortcut-help-modal__main-shortcuts", 757 shortcuts: ["core/customize-widgets/keyboard-shortcuts"] 758 } 759 ), 760 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 761 ShortcutCategorySection, 762 { 763 title: (0, import_i18n5.__)("Global shortcuts"), 764 categoryName: "global" 765 } 766 ), 767 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 768 ShortcutCategorySection, 769 { 770 title: (0, import_i18n5.__)("Selection shortcuts"), 771 categoryName: "selection" 772 } 773 ), 774 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 775 ShortcutCategorySection, 776 { 777 title: (0, import_i18n5.__)("Block shortcuts"), 778 categoryName: "block", 779 additionalShortcuts: [ 780 { 781 keyCombination: { character: "/" }, 782 description: (0, import_i18n5.__)( 783 "Change the block type after adding a new paragraph." 784 ), 785 /* translators: The forward-slash character. e.g. '/'. */ 786 ariaLabel: (0, import_i18n5.__)("Forward-slash") 787 } 788 ] 789 } 790 ), 791 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)( 792 ShortcutSection, 793 { 794 title: (0, import_i18n5.__)("Text formatting"), 795 shortcuts: textFormattingShortcuts 796 } 797 ) 798 ] 799 } 800 ); 801 } 802 803 // packages/customize-widgets/build-module/components/more-menu/index.js 804 var import_jsx_runtime13 = __toESM(require_jsx_runtime()); 805 function MoreMenu() { 806 const [ 807 isKeyboardShortcutsModalActive, 808 setIsKeyboardShortcutsModalVisible 809 ] = (0, import_element5.useState)(false); 810 const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive); 811 (0, import_keyboard_shortcuts3.useShortcut)( 812 "core/customize-widgets/keyboard-shortcuts", 813 toggleKeyboardShortcutsModal 814 ); 815 return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [ 816 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 817 import_components5.ToolbarDropdownMenu, 818 { 819 icon: more_vertical_default, 820 label: (0, import_i18n6.__)("Options"), 821 popoverProps: { 822 placement: "bottom-end", 823 className: "more-menu-dropdown__content" 824 }, 825 toggleProps: { 826 tooltipPosition: "bottom", 827 size: "compact" 828 }, 829 children: () => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [ 830 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components5.MenuGroup, { label: (0, import_i18n6._x)("View", "noun"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 831 import_preferences.PreferenceToggleMenuItem, 832 { 833 scope: "core/customize-widgets", 834 name: "fixedToolbar", 835 label: (0, import_i18n6.__)("Top toolbar"), 836 info: (0, import_i18n6.__)( 837 "Access all block and document tools in a single place" 838 ), 839 messageActivated: (0, import_i18n6.__)( 840 "Top toolbar activated" 841 ), 842 messageDeactivated: (0, import_i18n6.__)( 843 "Top toolbar deactivated" 844 ) 845 } 846 ) }), 847 /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components5.MenuGroup, { label: (0, import_i18n6.__)("Tools"), children: [ 848 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 849 import_components5.MenuItem, 850 { 851 onClick: () => { 852 setIsKeyboardShortcutsModalVisible(true); 853 }, 854 shortcut: import_keycodes2.displayShortcut.access("h"), 855 children: (0, import_i18n6.__)("Keyboard shortcuts") 856 } 857 ), 858 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 859 import_preferences.PreferenceToggleMenuItem, 860 { 861 scope: "core/customize-widgets", 862 name: "welcomeGuide", 863 label: (0, import_i18n6.__)("Welcome Guide") 864 } 865 ), 866 /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)( 867 import_components5.MenuItem, 868 { 869 role: "menuitem", 870 icon: external_default, 871 href: (0, import_i18n6.__)( 872 "https://wordpress.org/documentation/article/block-based-widgets-editor/" 873 ), 874 target: "_blank", 875 rel: "noopener noreferrer", 876 children: [ 877 (0, import_i18n6.__)("Help"), 878 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components5.VisuallyHidden, { 879 as: "span", 880 /* translators: accessibility text */ 881 children: (0, import_i18n6.__)("(opens in a new tab)") 882 }) 883 ] 884 } 885 ) 886 ] }), 887 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components5.MenuGroup, { label: (0, import_i18n6.__)("Preferences"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 888 import_preferences.PreferenceToggleMenuItem, 889 { 890 scope: "core/customize-widgets", 891 name: "keepCaretInsideBlock", 892 label: (0, import_i18n6.__)( 893 "Contain text cursor inside block" 894 ), 895 info: (0, import_i18n6.__)( 896 "Aids screen readers by stopping text caret from leaving blocks." 897 ), 898 messageActivated: (0, import_i18n6.__)( 899 "Contain text cursor inside block activated" 900 ), 901 messageDeactivated: (0, import_i18n6.__)( 902 "Contain text cursor inside block deactivated" 903 ) 904 } 905 ) }) 906 ] }) 907 } 908 ), 909 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)( 910 KeyboardShortcutHelpModal, 911 { 912 isModalActive: isKeyboardShortcutsModalActive, 913 toggleModal: toggleKeyboardShortcutsModal 914 } 915 ) 916 ] }); 917 } 918 919 // packages/customize-widgets/build-module/components/header/index.js 920 var import_jsx_runtime14 = __toESM(require_jsx_runtime()); 921 function Header({ 922 sidebar, 923 inserter, 924 isInserterOpened: isInserterOpened2, 925 setIsInserterOpened: setIsInserterOpened2, 926 isFixedToolbarActive 927 }) { 928 const [[hasUndo, hasRedo], setUndoRedo] = (0, import_element6.useState)([ 929 sidebar.hasUndo(), 930 sidebar.hasRedo() 931 ]); 932 const shortcut = (0, import_keycodes3.isAppleOS)() ? import_keycodes3.displayShortcut.primaryShift("z") : import_keycodes3.displayShortcut.primary("y"); 933 (0, import_element6.useEffect)(() => { 934 return sidebar.subscribeHistory(() => { 935 setUndoRedo([sidebar.hasUndo(), sidebar.hasRedo()]); 936 }); 937 }, [sidebar]); 938 return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [ 939 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 940 "div", 941 { 942 className: clsx_default("customize-widgets-header", { 943 "is-fixed-toolbar-active": isFixedToolbarActive 944 }), 945 children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)( 946 import_block_editor4.NavigableToolbar, 947 { 948 className: "customize-widgets-header-toolbar", 949 "aria-label": (0, import_i18n7.__)("Document tools"), 950 children: [ 951 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 952 import_components6.ToolbarButton, 953 { 954 icon: !(0, import_i18n7.isRTL)() ? undo_default : redo_default, 955 label: (0, import_i18n7.__)("Undo"), 956 shortcut: import_keycodes3.displayShortcut.primary("z"), 957 disabled: !hasUndo, 958 onClick: sidebar.undo, 959 className: "customize-widgets-editor-history-button undo-button" 960 } 961 ), 962 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 963 import_components6.ToolbarButton, 964 { 965 icon: !(0, import_i18n7.isRTL)() ? redo_default : undo_default, 966 label: (0, import_i18n7.__)("Redo"), 967 shortcut, 968 disabled: !hasRedo, 969 onClick: sidebar.redo, 970 className: "customize-widgets-editor-history-button redo-button" 971 } 972 ), 973 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 974 import_components6.ToolbarButton, 975 { 976 className: "customize-widgets-header-toolbar__inserter-toggle", 977 isPressed: isInserterOpened2, 978 variant: "primary", 979 icon: plus_default, 980 label: (0, import_i18n7._x)( 981 "Add block", 982 "Generic label for block inserter button" 983 ), 984 onClick: () => { 985 setIsInserterOpened2((isOpen) => !isOpen); 986 } 987 } 988 ), 989 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MoreMenu, {}) 990 ] 991 } 992 ) 993 } 994 ), 995 (0, import_element6.createPortal)( 996 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(inserter_default, { setIsOpened: setIsInserterOpened2 }), 997 inserter.contentContainer[0] 998 ) 999 ] }); 1000 } 1001 var header_default = Header; 1002 1003 // packages/customize-widgets/build-module/components/inserter/use-inserter.js 1004 var import_element7 = __toESM(require_element()); 1005 var import_data7 = __toESM(require_data()); 1006 function useInserter(inserter) { 1007 const isInserterOpened2 = (0, import_data7.useSelect)( 1008 (select) => select(store).isInserterOpened(), 1009 [] 1010 ); 1011 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data7.useDispatch)(store); 1012 (0, import_element7.useEffect)(() => { 1013 if (isInserterOpened2) { 1014 inserter.open(); 1015 } else { 1016 inserter.close(); 1017 } 1018 }, [inserter, isInserterOpened2]); 1019 return [ 1020 isInserterOpened2, 1021 (0, import_element7.useCallback)( 1022 (updater) => { 1023 let isOpen = updater; 1024 if (typeof updater === "function") { 1025 isOpen = updater( 1026 (0, import_data7.select)(store).isInserterOpened() 1027 ); 1028 } 1029 setIsInserterOpened2(isOpen); 1030 }, 1031 [setIsInserterOpened2] 1032 ) 1033 ]; 1034 } 1035 1036 // packages/customize-widgets/build-module/components/sidebar-block-editor/sidebar-editor-provider.js 1037 var import_block_editor6 = __toESM(require_block_editor()); 1038 1039 // packages/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js 1040 var import_es6 = __toESM(require_es6()); 1041 var import_element8 = __toESM(require_element()); 1042 var import_is_shallow_equal = __toESM(require_is_shallow_equal()); 1043 var import_widgets2 = __toESM(require_widgets()); 1044 1045 // packages/customize-widgets/build-module/utils.js 1046 var import_blocks = __toESM(require_blocks()); 1047 var import_widgets = __toESM(require_widgets()); 1048 function settingIdToWidgetId(settingId) { 1049 const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/); 1050 if (matches) { 1051 const idBase = matches[1]; 1052 const number = parseInt(matches[2], 10); 1053 return `$idBase}-$number}`; 1054 } 1055 return settingId; 1056 } 1057 function blockToWidget(block, existingWidget = null) { 1058 let widget; 1059 const isValidLegacyWidgetBlock = block.name === "core/legacy-widget" && (block.attributes.id || block.attributes.instance); 1060 if (isValidLegacyWidgetBlock) { 1061 if (block.attributes.id) { 1062 widget = { 1063 id: block.attributes.id 1064 }; 1065 } else { 1066 const { encoded, hash, raw, ...rest } = block.attributes.instance; 1067 widget = { 1068 idBase: block.attributes.idBase, 1069 instance: { 1070 ...existingWidget?.instance, 1071 // Required only for the customizer. 1072 is_widget_customizer_js_value: true, 1073 encoded_serialized_instance: encoded, 1074 instance_hash_key: hash, 1075 raw_instance: raw, 1076 ...rest 1077 } 1078 }; 1079 } 1080 } else { 1081 const instance = { 1082 content: (0, import_blocks.serialize)(block) 1083 }; 1084 widget = { 1085 idBase: "block", 1086 widgetClass: "WP_Widget_Block", 1087 instance: { 1088 raw_instance: instance 1089 } 1090 }; 1091 } 1092 const { form, rendered, ...restExistingWidget } = existingWidget || {}; 1093 return { 1094 ...restExistingWidget, 1095 ...widget 1096 }; 1097 } 1098 function widgetToBlock({ id, idBase, number, instance }) { 1099 let block; 1100 const { 1101 encoded_serialized_instance: encoded, 1102 instance_hash_key: hash, 1103 raw_instance: raw, 1104 ...rest 1105 } = instance; 1106 if (idBase === "block") { 1107 const parsedBlocks = (0, import_blocks.parse)(raw.content ?? "", { 1108 __unstableSkipAutop: true 1109 }); 1110 block = parsedBlocks.length ? parsedBlocks[0] : (0, import_blocks.createBlock)("core/paragraph", {}); 1111 } else if (number) { 1112 block = (0, import_blocks.createBlock)("core/legacy-widget", { 1113 idBase, 1114 instance: { 1115 encoded, 1116 hash, 1117 raw, 1118 ...rest 1119 } 1120 }); 1121 } else { 1122 block = (0, import_blocks.createBlock)("core/legacy-widget", { 1123 id 1124 }); 1125 } 1126 return (0, import_widgets.addWidgetIdToBlock)(block, id); 1127 } 1128 1129 // packages/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.js 1130 function widgetsToBlocks(widgets) { 1131 return widgets.map((widget) => widgetToBlock(widget)); 1132 } 1133 function useSidebarBlockEditor(sidebar) { 1134 const [blocks, setBlocks] = (0, import_element8.useState)( 1135 () => widgetsToBlocks(sidebar.getWidgets()) 1136 ); 1137 (0, import_element8.useEffect)(() => { 1138 return sidebar.subscribe((prevWidgets, nextWidgets) => { 1139 setBlocks((prevBlocks) => { 1140 const prevWidgetsMap = new Map( 1141 prevWidgets.map((widget) => [widget.id, widget]) 1142 ); 1143 const prevBlocksMap = new Map( 1144 prevBlocks.map((block) => [ 1145 (0, import_widgets2.getWidgetIdFromBlock)(block), 1146 block 1147 ]) 1148 ); 1149 const nextBlocks = nextWidgets.map((nextWidget) => { 1150 const prevWidget = prevWidgetsMap.get(nextWidget.id); 1151 if (prevWidget && prevWidget === nextWidget) { 1152 return prevBlocksMap.get(nextWidget.id); 1153 } 1154 return widgetToBlock(nextWidget); 1155 }); 1156 if ((0, import_is_shallow_equal.default)(prevBlocks, nextBlocks)) { 1157 return prevBlocks; 1158 } 1159 return nextBlocks; 1160 }); 1161 }); 1162 }, [sidebar]); 1163 const onChangeBlocks = (0, import_element8.useCallback)( 1164 (nextBlocks) => { 1165 setBlocks((prevBlocks) => { 1166 if ((0, import_is_shallow_equal.default)(prevBlocks, nextBlocks)) { 1167 return prevBlocks; 1168 } 1169 const prevBlocksMap = new Map( 1170 prevBlocks.map((block) => [ 1171 (0, import_widgets2.getWidgetIdFromBlock)(block), 1172 block 1173 ]) 1174 ); 1175 const nextWidgets = nextBlocks.map((nextBlock) => { 1176 const widgetId = (0, import_widgets2.getWidgetIdFromBlock)(nextBlock); 1177 if (widgetId && prevBlocksMap.has(widgetId)) { 1178 const prevBlock = prevBlocksMap.get(widgetId); 1179 const prevWidget = sidebar.getWidget(widgetId); 1180 if ((0, import_es6.default)(nextBlock, prevBlock) && prevWidget) { 1181 return prevWidget; 1182 } 1183 return blockToWidget(nextBlock, prevWidget); 1184 } 1185 return blockToWidget(nextBlock); 1186 }); 1187 if ((0, import_is_shallow_equal.default)(sidebar.getWidgets(), nextWidgets)) { 1188 return prevBlocks; 1189 } 1190 const addedWidgetIds = sidebar.setWidgets(nextWidgets); 1191 return nextBlocks.reduce( 1192 (updatedNextBlocks, nextBlock, index) => { 1193 const addedWidgetId = addedWidgetIds[index]; 1194 if (addedWidgetId !== null) { 1195 if (updatedNextBlocks === nextBlocks) { 1196 updatedNextBlocks = nextBlocks.slice(); 1197 } 1198 updatedNextBlocks[index] = (0, import_widgets2.addWidgetIdToBlock)( 1199 nextBlock, 1200 addedWidgetId 1201 ); 1202 } 1203 return updatedNextBlocks; 1204 }, 1205 nextBlocks 1206 ); 1207 }); 1208 }, 1209 [sidebar] 1210 ); 1211 return [blocks, onChangeBlocks, onChangeBlocks]; 1212 } 1213 1214 // packages/customize-widgets/build-module/components/focus-control/use-blocks-focus-control.js 1215 var import_element10 = __toESM(require_element()); 1216 var import_data8 = __toESM(require_data()); 1217 var import_block_editor5 = __toESM(require_block_editor()); 1218 var import_widgets3 = __toESM(require_widgets()); 1219 1220 // packages/customize-widgets/build-module/components/focus-control/index.js 1221 var import_element9 = __toESM(require_element()); 1222 var import_jsx_runtime15 = __toESM(require_jsx_runtime()); 1223 var FocusControlContext = (0, import_element9.createContext)(); 1224 FocusControlContext.displayName = "FocusControlContext"; 1225 function FocusControl({ api, sidebarControls, children }) { 1226 const [focusedWidgetIdRef, setFocusedWidgetIdRef] = (0, import_element9.useState)({ 1227 current: null 1228 }); 1229 const focusWidget = (0, import_element9.useCallback)( 1230 (widgetId) => { 1231 for (const sidebarControl of sidebarControls) { 1232 const widgets = sidebarControl.setting.get(); 1233 if (widgets.includes(widgetId)) { 1234 sidebarControl.sectionInstance.expand({ 1235 // Schedule it after the complete callback so that 1236 // it won't be overridden by the "Back" button focus. 1237 completeCallback() { 1238 setFocusedWidgetIdRef({ current: widgetId }); 1239 } 1240 }); 1241 break; 1242 } 1243 } 1244 }, 1245 [sidebarControls] 1246 ); 1247 (0, import_element9.useEffect)(() => { 1248 function handleFocus(settingId) { 1249 const widgetId = settingIdToWidgetId(settingId); 1250 focusWidget(widgetId); 1251 } 1252 let previewBound = false; 1253 function handleReady() { 1254 api.previewer.preview.bind( 1255 "focus-control-for-setting", 1256 handleFocus 1257 ); 1258 previewBound = true; 1259 } 1260 api.previewer.bind("ready", handleReady); 1261 return () => { 1262 api.previewer.unbind("ready", handleReady); 1263 if (previewBound) { 1264 api.previewer.preview.unbind( 1265 "focus-control-for-setting", 1266 handleFocus 1267 ); 1268 } 1269 }; 1270 }, [api, focusWidget]); 1271 const context = (0, import_element9.useMemo)( 1272 () => [focusedWidgetIdRef, focusWidget], 1273 [focusedWidgetIdRef, focusWidget] 1274 ); 1275 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FocusControlContext.Provider, { value: context, children }); 1276 } 1277 var useFocusControl = () => (0, import_element9.useContext)(FocusControlContext); 1278 1279 // packages/customize-widgets/build-module/components/focus-control/use-blocks-focus-control.js 1280 function useBlocksFocusControl(blocks) { 1281 const { selectBlock } = (0, import_data8.useDispatch)(import_block_editor5.store); 1282 const [focusedWidgetIdRef] = useFocusControl(); 1283 const blocksRef = (0, import_element10.useRef)(blocks); 1284 (0, import_element10.useEffect)(() => { 1285 blocksRef.current = blocks; 1286 }, [blocks]); 1287 (0, import_element10.useEffect)(() => { 1288 if (focusedWidgetIdRef.current) { 1289 const focusedBlock = blocksRef.current.find( 1290 (block) => (0, import_widgets3.getWidgetIdFromBlock)(block) === focusedWidgetIdRef.current 1291 ); 1292 if (focusedBlock) { 1293 selectBlock(focusedBlock.clientId); 1294 const blockNode = document.querySelector( 1295 `[data-block="$focusedBlock.clientId}"]` 1296 ); 1297 blockNode?.focus(); 1298 } 1299 } 1300 }, [focusedWidgetIdRef, selectBlock]); 1301 } 1302 1303 // packages/customize-widgets/build-module/lock-unlock.js 1304 var import_private_apis = __toESM(require_private_apis()); 1305 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 1306 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 1307 "@wordpress/customize-widgets" 1308 ); 1309 1310 // packages/customize-widgets/build-module/components/sidebar-block-editor/sidebar-editor-provider.js 1311 var import_jsx_runtime16 = __toESM(require_jsx_runtime()); 1312 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor6.privateApis); 1313 function SidebarEditorProvider({ 1314 sidebar, 1315 settings, 1316 children 1317 }) { 1318 const [blocks, onInput, onChange] = useSidebarBlockEditor(sidebar); 1319 useBlocksFocusControl(blocks); 1320 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( 1321 ExperimentalBlockEditorProvider, 1322 { 1323 value: blocks, 1324 onInput, 1325 onChange, 1326 settings, 1327 useSubRegistry: false, 1328 children 1329 } 1330 ); 1331 } 1332 1333 // packages/customize-widgets/build-module/components/welcome-guide/index.js 1334 var import_i18n8 = __toESM(require_i18n()); 1335 var import_components7 = __toESM(require_components()); 1336 var import_data9 = __toESM(require_data()); 1337 var import_preferences2 = __toESM(require_preferences()); 1338 var import_jsx_runtime17 = __toESM(require_jsx_runtime()); 1339 function WelcomeGuide({ sidebar }) { 1340 const { toggle } = (0, import_data9.useDispatch)(import_preferences2.store); 1341 const isEntirelyBlockWidgets = sidebar.getWidgets().every((widget) => widget.id.startsWith("block-")); 1342 return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "customize-widgets-welcome-guide", children: [ 1343 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "customize-widgets-welcome-guide__image__wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("picture", { children: [ 1344 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 1345 "source", 1346 { 1347 srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg", 1348 media: "(prefers-reduced-motion: reduce)" 1349 } 1350 ), 1351 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 1352 "img", 1353 { 1354 className: "customize-widgets-welcome-guide__image", 1355 src: "https://s.w.org/images/block-editor/welcome-editor.gif", 1356 width: "312", 1357 height: "240", 1358 alt: "" 1359 } 1360 ) 1361 ] }) }), 1362 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "customize-widgets-welcome-guide__heading", children: (0, import_i18n8.__)("Welcome to block Widgets") }), 1363 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "customize-widgets-welcome-guide__text", children: isEntirelyBlockWidgets ? (0, import_i18n8.__)( 1364 "Your theme provides 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." 1365 ) : (0, import_i18n8.__)( 1366 "You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly." 1367 ) }), 1368 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 1369 import_components7.Button, 1370 { 1371 size: "compact", 1372 variant: "primary", 1373 onClick: () => toggle("core/customize-widgets", "welcomeGuide"), 1374 children: (0, import_i18n8.__)("Got it") 1375 } 1376 ), 1377 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", { className: "customize-widgets-welcome-guide__separator" }), 1378 !isEntirelyBlockWidgets && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { className: "customize-widgets-welcome-guide__more-info", children: [ 1379 (0, import_i18n8.__)("Want to stick with the old widgets?"), 1380 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("br", {}), 1381 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 1382 import_components7.ExternalLink, 1383 { 1384 href: (0, import_i18n8.__)( 1385 "https://wordpress.org/plugins/classic-widgets/" 1386 ), 1387 children: (0, import_i18n8.__)("Get the Classic Widgets plugin.") 1388 } 1389 ) 1390 ] }), 1391 /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { className: "customize-widgets-welcome-guide__more-info", children: [ 1392 (0, import_i18n8.__)("New to the block editor?"), 1393 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("br", {}), 1394 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( 1395 import_components7.ExternalLink, 1396 { 1397 href: (0, import_i18n8.__)( 1398 "https://wordpress.org/documentation/article/wordpress-block-editor/" 1399 ), 1400 children: (0, import_i18n8.__)("Here's a detailed guide.") 1401 } 1402 ) 1403 ] }) 1404 ] }); 1405 } 1406 1407 // packages/customize-widgets/build-module/components/keyboard-shortcuts/index.js 1408 var import_element11 = __toESM(require_element()); 1409 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts()); 1410 var import_keycodes4 = __toESM(require_keycodes()); 1411 var import_data10 = __toESM(require_data()); 1412 var import_i18n9 = __toESM(require_i18n()); 1413 function KeyboardShortcuts({ undo, redo, save }) { 1414 (0, import_keyboard_shortcuts4.useShortcut)("core/customize-widgets/undo", (event) => { 1415 undo(); 1416 event.preventDefault(); 1417 }); 1418 (0, import_keyboard_shortcuts4.useShortcut)("core/customize-widgets/redo", (event) => { 1419 redo(); 1420 event.preventDefault(); 1421 }); 1422 (0, import_keyboard_shortcuts4.useShortcut)("core/customize-widgets/save", (event) => { 1423 event.preventDefault(); 1424 save(); 1425 }); 1426 return null; 1427 } 1428 function KeyboardShortcutsRegister() { 1429 const { registerShortcut, unregisterShortcut } = (0, import_data10.useDispatch)( 1430 import_keyboard_shortcuts4.store 1431 ); 1432 (0, import_element11.useEffect)(() => { 1433 registerShortcut({ 1434 name: "core/customize-widgets/undo", 1435 category: "global", 1436 description: (0, import_i18n9.__)("Undo your last changes."), 1437 keyCombination: { 1438 modifier: "primary", 1439 character: "z" 1440 } 1441 }); 1442 registerShortcut({ 1443 name: "core/customize-widgets/redo", 1444 category: "global", 1445 description: (0, import_i18n9.__)("Redo your last undo."), 1446 keyCombination: { 1447 modifier: "primaryShift", 1448 character: "z" 1449 }, 1450 // Disable on Apple OS because it conflicts with the browser's 1451 // history shortcut. It's a fine alias for both Windows and Linux. 1452 // Since there's no conflict for Ctrl+Shift+Z on both Windows and 1453 // Linux, we keep it as the default for consistency. 1454 aliases: (0, import_keycodes4.isAppleOS)() ? [] : [ 1455 { 1456 modifier: "primary", 1457 character: "y" 1458 } 1459 ] 1460 }); 1461 registerShortcut({ 1462 name: "core/customize-widgets/save", 1463 category: "global", 1464 description: (0, import_i18n9.__)("Save your changes."), 1465 keyCombination: { 1466 modifier: "primary", 1467 character: "s" 1468 } 1469 }); 1470 return () => { 1471 unregisterShortcut("core/customize-widgets/undo"); 1472 unregisterShortcut("core/customize-widgets/redo"); 1473 unregisterShortcut("core/customize-widgets/save"); 1474 }; 1475 }, [registerShortcut]); 1476 return null; 1477 } 1478 KeyboardShortcuts.Register = KeyboardShortcutsRegister; 1479 var keyboard_shortcuts_default = KeyboardShortcuts; 1480 1481 // packages/customize-widgets/build-module/components/block-appender/index.js 1482 var import_element12 = __toESM(require_element()); 1483 var import_block_editor7 = __toESM(require_block_editor()); 1484 var import_data11 = __toESM(require_data()); 1485 var import_jsx_runtime18 = __toESM(require_jsx_runtime()); 1486 function BlockAppender(props) { 1487 const ref = (0, import_element12.useRef)(); 1488 const isBlocksListEmpty = (0, import_data11.useSelect)( 1489 (select) => select(import_block_editor7.store).getBlockCount() === 0 1490 ); 1491 (0, import_element12.useEffect)(() => { 1492 if (isBlocksListEmpty && ref.current) { 1493 const { ownerDocument } = ref.current; 1494 if (!ownerDocument.activeElement || ownerDocument.activeElement === ownerDocument.body) { 1495 ref.current.focus(); 1496 } 1497 } 1498 }, [isBlocksListEmpty]); 1499 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_block_editor7.ButtonBlockAppender, { ...props, ref }); 1500 } 1501 1502 // packages/customize-widgets/build-module/components/sidebar-block-editor/index.js 1503 var import_jsx_runtime19 = __toESM(require_jsx_runtime()); 1504 var { ExperimentalBlockCanvas: BlockCanvas } = unlock( 1505 import_block_editor8.privateApis 1506 ); 1507 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis); 1508 function SidebarBlockEditor({ 1509 blockEditorSettings, 1510 sidebar, 1511 inserter, 1512 inspector 1513 }) { 1514 const [isInserterOpened2, setIsInserterOpened2] = useInserter(inserter); 1515 const isMediumViewport = (0, import_compose3.useViewportMatch)("small"); 1516 const { 1517 hasUploadPermissions, 1518 isFixedToolbarActive, 1519 keepCaretInsideBlock, 1520 isWelcomeGuideActive 1521 } = (0, import_data12.useSelect)((select) => { 1522 const { get } = select(import_preferences3.store); 1523 return { 1524 hasUploadPermissions: select(import_core_data.store).canUser("create", { 1525 kind: "postType", 1526 name: "attachment" 1527 }) ?? true, 1528 isFixedToolbarActive: !!get( 1529 "core/customize-widgets", 1530 "fixedToolbar" 1531 ), 1532 keepCaretInsideBlock: !!get( 1533 "core/customize-widgets", 1534 "keepCaretInsideBlock" 1535 ), 1536 isWelcomeGuideActive: !!get( 1537 "core/customize-widgets", 1538 "welcomeGuide" 1539 ) 1540 }; 1541 }, []); 1542 const settings = (0, import_element13.useMemo)(() => { 1543 let mediaUploadBlockEditor; 1544 if (hasUploadPermissions) { 1545 mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => { 1546 (0, import_media_utils.uploadMedia)({ 1547 wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes, 1548 onError: ({ message }) => onError(message), 1549 ...argumentsObject 1550 }); 1551 }; 1552 } 1553 return { 1554 ...blockEditorSettings, 1555 __experimentalSetIsInserterOpened: setIsInserterOpened2, 1556 mediaUpload: mediaUploadBlockEditor, 1557 hasFixedToolbar: isFixedToolbarActive || !isMediumViewport, 1558 keepCaretInsideBlock, 1559 editorTool: "edit", 1560 __unstableHasCustomAppender: true 1561 }; 1562 }, [ 1563 hasUploadPermissions, 1564 blockEditorSettings, 1565 isFixedToolbarActive, 1566 isMediumViewport, 1567 keepCaretInsideBlock, 1568 setIsInserterOpened2 1569 ]); 1570 if (isWelcomeGuideActive) { 1571 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(WelcomeGuide, { sidebar }); 1572 } 1573 return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [ 1574 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(keyboard_shortcuts_default.Register, {}), 1575 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BlockKeyboardShortcuts, {}), 1576 /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(SidebarEditorProvider, { sidebar, settings, children: [ 1577 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1578 keyboard_shortcuts_default, 1579 { 1580 undo: sidebar.undo, 1581 redo: sidebar.redo, 1582 save: sidebar.save 1583 } 1584 ), 1585 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1586 header_default, 1587 { 1588 sidebar, 1589 inserter, 1590 isInserterOpened: isInserterOpened2, 1591 setIsInserterOpened: setIsInserterOpened2, 1592 isFixedToolbarActive: isFixedToolbarActive || !isMediumViewport 1593 } 1594 ), 1595 (isFixedToolbarActive || !isMediumViewport) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.BlockToolbar, { hideDragHandle: true }), 1596 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1597 BlockCanvas, 1598 { 1599 shouldIframe: false, 1600 styles: settings.defaultEditorStyles, 1601 height: "100%", 1602 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.BlockList, { renderAppender: BlockAppender }) 1603 } 1604 ), 1605 (0, import_element13.createPortal)( 1606 // This is a temporary hack to prevent button component inside <BlockInspector> 1607 // from submitting form when type="button" is not specified. 1608 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("form", { onSubmit: (event) => event.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.BlockInspector, {}) }), 1609 inspector.contentContainer[0] 1610 ) 1611 ] }), 1612 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.__unstableBlockSettingsMenuFirstItem, { children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)( 1613 block_inspector_button_default, 1614 { 1615 inspector, 1616 closeMenu: onClose 1617 } 1618 ) }) 1619 ] }); 1620 } 1621 1622 // packages/customize-widgets/build-module/components/sidebar-controls/index.js 1623 var import_element14 = __toESM(require_element()); 1624 var import_jsx_runtime20 = __toESM(require_jsx_runtime()); 1625 var SidebarControlsContext = (0, import_element14.createContext)(); 1626 SidebarControlsContext.displayName = "SidebarControlsContext"; 1627 function SidebarControls({ 1628 sidebarControls, 1629 activeSidebarControl, 1630 children 1631 }) { 1632 const context = (0, import_element14.useMemo)( 1633 () => ({ 1634 sidebarControls, 1635 activeSidebarControl 1636 }), 1637 [sidebarControls, activeSidebarControl] 1638 ); 1639 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SidebarControlsContext.Provider, { value: context, children }); 1640 } 1641 function useSidebarControls() { 1642 const { sidebarControls } = (0, import_element14.useContext)(SidebarControlsContext); 1643 return sidebarControls; 1644 } 1645 function useActiveSidebarControl() { 1646 const { activeSidebarControl } = (0, import_element14.useContext)(SidebarControlsContext); 1647 return activeSidebarControl; 1648 } 1649 1650 // packages/customize-widgets/build-module/components/customize-widgets/use-clear-selected-block.js 1651 var import_element15 = __toESM(require_element()); 1652 var import_data13 = __toESM(require_data()); 1653 var import_block_editor9 = __toESM(require_block_editor()); 1654 function useClearSelectedBlock(sidebarControl, popoverRef) { 1655 const { hasSelectedBlock, hasMultiSelection } = (0, import_data13.useSelect)(import_block_editor9.store); 1656 const { clearSelectedBlock } = (0, import_data13.useDispatch)(import_block_editor9.store); 1657 (0, import_element15.useEffect)(() => { 1658 if (popoverRef.current && sidebarControl) { 1659 let handleClearSelectedBlock = function(element) { 1660 if ( 1661 // 1. Make sure there are blocks being selected. 1662 (hasSelectedBlock() || hasMultiSelection()) && // 2. The element should exist in the DOM (not deleted). 1663 element && ownerDocument.contains(element) && // 3. It should also not exist in the container, the popover, nor the dialog. 1664 !container.contains(element) && !popoverRef.current.contains(element) && !element.closest('[role="dialog"]') && // 4. The inspector should not be opened. 1665 !inspector.expanded() 1666 ) { 1667 clearSelectedBlock(); 1668 } 1669 }, handleMouseDown = function(event) { 1670 handleClearSelectedBlock(event.target); 1671 }, handleBlur = function() { 1672 handleClearSelectedBlock(ownerDocument.activeElement); 1673 }; 1674 const inspector = sidebarControl.inspector; 1675 const container = sidebarControl.container[0]; 1676 const ownerDocument = container.ownerDocument; 1677 const ownerWindow = ownerDocument.defaultView; 1678 ownerDocument.addEventListener("mousedown", handleMouseDown); 1679 ownerWindow.addEventListener("blur", handleBlur); 1680 return () => { 1681 ownerDocument.removeEventListener( 1682 "mousedown", 1683 handleMouseDown 1684 ); 1685 ownerWindow.removeEventListener("blur", handleBlur); 1686 }; 1687 } 1688 }, [ 1689 popoverRef, 1690 sidebarControl, 1691 hasSelectedBlock, 1692 hasMultiSelection, 1693 clearSelectedBlock 1694 ]); 1695 } 1696 1697 // packages/customize-widgets/build-module/components/customize-widgets/index.js 1698 var import_jsx_runtime21 = __toESM(require_jsx_runtime()); 1699 function CustomizeWidgets({ 1700 api, 1701 sidebarControls, 1702 blockEditorSettings 1703 }) { 1704 const [activeSidebarControl, setActiveSidebarControl] = (0, import_element16.useState)(null); 1705 const parentContainer = document.getElementById( 1706 "customize-theme-controls" 1707 ); 1708 const popoverRef = (0, import_element16.useRef)(); 1709 useClearSelectedBlock(activeSidebarControl, popoverRef); 1710 (0, import_element16.useEffect)(() => { 1711 const unsubscribers = sidebarControls.map( 1712 (sidebarControl) => sidebarControl.subscribe((expanded) => { 1713 if (expanded) { 1714 setActiveSidebarControl(sidebarControl); 1715 } 1716 }) 1717 ); 1718 return () => { 1719 unsubscribers.forEach((unsubscriber) => unsubscriber()); 1720 }; 1721 }, [sidebarControls]); 1722 const activeSidebar = activeSidebarControl && (0, import_element16.createPortal)( 1723 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1724 SidebarBlockEditor, 1725 { 1726 blockEditorSettings, 1727 sidebar: activeSidebarControl.sidebarAdapter, 1728 inserter: activeSidebarControl.inserter, 1729 inspector: activeSidebarControl.inspector 1730 }, 1731 activeSidebarControl.id 1732 ) }), 1733 activeSidebarControl.container[0] 1734 ); 1735 const popover = parentContainer && (0, import_element16.createPortal)( 1736 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "customize-widgets-popover", ref: popoverRef, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components8.Popover.Slot, {}) }), 1737 parentContainer 1738 ); 1739 return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components8.SlotFillProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)( 1740 SidebarControls, 1741 { 1742 sidebarControls, 1743 activeSidebarControl, 1744 children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(FocusControl, { api, sidebarControls, children: [ 1745 activeSidebar, 1746 popover 1747 ] }) 1748 } 1749 ) }); 1750 } 1751 1752 // packages/customize-widgets/build-module/controls/sidebar-section.js 1753 var import_i18n10 = __toESM(require_i18n()); 1754 1755 // packages/customize-widgets/build-module/controls/inspector-section.js 1756 function getInspectorSection() { 1757 const { 1758 wp: { customize } 1759 } = window; 1760 return class InspectorSection extends customize.Section { 1761 constructor(id, options) { 1762 super(id, options); 1763 this.parentSection = options.parentSection; 1764 this.returnFocusWhenClose = null; 1765 this._isOpen = false; 1766 } 1767 get isOpen() { 1768 return this._isOpen; 1769 } 1770 set isOpen(value) { 1771 this._isOpen = value; 1772 this.triggerActiveCallbacks(); 1773 } 1774 ready() { 1775 this.contentContainer[0].classList.add( 1776 "customize-widgets-layout__inspector" 1777 ); 1778 } 1779 isContextuallyActive() { 1780 return this.isOpen; 1781 } 1782 onChangeExpanded(expanded, args) { 1783 super.onChangeExpanded(expanded, args); 1784 if (this.parentSection && !args.unchanged) { 1785 if (expanded) { 1786 this.parentSection.collapse({ 1787 manualTransition: true 1788 }); 1789 } else { 1790 this.parentSection.expand({ 1791 manualTransition: true, 1792 completeCallback: () => { 1793 if (this.returnFocusWhenClose && !this.contentContainer[0].contains( 1794 this.returnFocusWhenClose 1795 )) { 1796 this.returnFocusWhenClose.focus(); 1797 } 1798 } 1799 }); 1800 } 1801 } 1802 } 1803 open({ returnFocusWhenClose } = {}) { 1804 this.isOpen = true; 1805 this.returnFocusWhenClose = returnFocusWhenClose; 1806 this.expand({ 1807 allowMultiple: true 1808 }); 1809 } 1810 close() { 1811 this.collapse({ 1812 allowMultiple: true 1813 }); 1814 } 1815 collapse(options) { 1816 this.isOpen = false; 1817 super.collapse(options); 1818 } 1819 triggerActiveCallbacks() { 1820 this.active.callbacks.fireWith(this.active, [false, true]); 1821 } 1822 }; 1823 } 1824 1825 // packages/customize-widgets/build-module/controls/sidebar-section.js 1826 var getInspectorSectionId = (sidebarId) => `widgets-inspector-$sidebarId}`; 1827 function getSidebarSection() { 1828 const { 1829 wp: { customize } 1830 } = window; 1831 const reduceMotionMediaQuery = window.matchMedia( 1832 "(prefers-reduced-motion: reduce)" 1833 ); 1834 let isReducedMotion = reduceMotionMediaQuery.matches; 1835 reduceMotionMediaQuery.addEventListener("change", (event) => { 1836 isReducedMotion = event.matches; 1837 }); 1838 return class SidebarSection extends customize.Section { 1839 ready() { 1840 const InspectorSection = getInspectorSection(); 1841 this.inspector = new InspectorSection( 1842 getInspectorSectionId(this.id), 1843 { 1844 title: (0, import_i18n10.__)("Block Settings"), 1845 parentSection: this, 1846 customizeAction: [ 1847 (0, import_i18n10.__)("Customizing"), 1848 (0, import_i18n10.__)("Widgets"), 1849 this.params.title 1850 ].join(" \u25B8 ") 1851 } 1852 ); 1853 customize.section.add(this.inspector); 1854 this.contentContainer[0].classList.add( 1855 "customize-widgets__sidebar-section" 1856 ); 1857 } 1858 hasSubSectionOpened() { 1859 return this.inspector.expanded(); 1860 } 1861 onChangeExpanded(expanded, _args) { 1862 const controls = this.controls(); 1863 const args = { 1864 ..._args, 1865 completeCallback() { 1866 controls.forEach((control) => { 1867 control.onChangeSectionExpanded?.(expanded, args); 1868 }); 1869 _args.completeCallback?.(); 1870 } 1871 }; 1872 if (args.manualTransition) { 1873 if (expanded) { 1874 this.contentContainer.addClass(["busy", "open"]); 1875 this.contentContainer.removeClass("is-sub-section-open"); 1876 this.contentContainer.closest(".wp-full-overlay").addClass("section-open"); 1877 } else { 1878 this.contentContainer.addClass([ 1879 "busy", 1880 "is-sub-section-open" 1881 ]); 1882 this.contentContainer.closest(".wp-full-overlay").addClass("section-open"); 1883 this.contentContainer.removeClass("open"); 1884 } 1885 const handleTransitionEnd = () => { 1886 this.contentContainer.removeClass("busy"); 1887 args.completeCallback(); 1888 }; 1889 if (isReducedMotion) { 1890 handleTransitionEnd(); 1891 } else { 1892 this.contentContainer.one( 1893 "transitionend", 1894 handleTransitionEnd 1895 ); 1896 } 1897 } else { 1898 super.onChangeExpanded(expanded, args); 1899 } 1900 } 1901 }; 1902 } 1903 1904 // packages/customize-widgets/build-module/controls/sidebar-control.js 1905 var import_data15 = __toESM(require_data()); 1906 1907 // packages/customize-widgets/build-module/components/sidebar-block-editor/sidebar-adapter.js 1908 var { wp } = window; 1909 function parseWidgetId(widgetId) { 1910 const matches = widgetId.match(/^(.+)-(\d+)$/); 1911 if (matches) { 1912 return { 1913 idBase: matches[1], 1914 number: parseInt(matches[2], 10) 1915 }; 1916 } 1917 return { idBase: widgetId }; 1918 } 1919 function widgetIdToSettingId(widgetId) { 1920 const { idBase, number } = parseWidgetId(widgetId); 1921 if (number) { 1922 return `widget_$idBase}[$number}]`; 1923 } 1924 return `widget_$idBase}`; 1925 } 1926 function debounce(leading, callback, timeout) { 1927 let isLeading = false; 1928 let timerID; 1929 function debounced(...args) { 1930 const result = (isLeading ? callback : leading).apply(this, args); 1931 isLeading = true; 1932 clearTimeout(timerID); 1933 timerID = setTimeout(() => { 1934 isLeading = false; 1935 }, timeout); 1936 return result; 1937 } 1938 debounced.cancel = () => { 1939 isLeading = false; 1940 clearTimeout(timerID); 1941 }; 1942 return debounced; 1943 } 1944 var SidebarAdapter = class { 1945 constructor(setting, api) { 1946 this.setting = setting; 1947 this.api = api; 1948 this.locked = false; 1949 this.widgetsCache = /* @__PURE__ */ new WeakMap(); 1950 this.subscribers = /* @__PURE__ */ new Set(); 1951 this.history = [ 1952 this._getWidgetIds().map( 1953 (widgetId) => this.getWidget(widgetId) 1954 ) 1955 ]; 1956 this.historyIndex = 0; 1957 this.historySubscribers = /* @__PURE__ */ new Set(); 1958 this._debounceSetHistory = debounce( 1959 this._pushHistory, 1960 this._replaceHistory, 1961 1e3 1962 ); 1963 this.setting.bind(this._handleSettingChange.bind(this)); 1964 this.api.bind("change", this._handleAllSettingsChange.bind(this)); 1965 this.undo = this.undo.bind(this); 1966 this.redo = this.redo.bind(this); 1967 this.save = this.save.bind(this); 1968 } 1969 subscribe(callback) { 1970 this.subscribers.add(callback); 1971 return () => { 1972 this.subscribers.delete(callback); 1973 }; 1974 } 1975 getWidgets() { 1976 return this.history[this.historyIndex]; 1977 } 1978 _emit(...args) { 1979 for (const callback of this.subscribers) { 1980 callback(...args); 1981 } 1982 } 1983 _getWidgetIds() { 1984 return this.setting.get(); 1985 } 1986 _pushHistory() { 1987 this.history = [ 1988 ...this.history.slice(0, this.historyIndex + 1), 1989 this._getWidgetIds().map( 1990 (widgetId) => this.getWidget(widgetId) 1991 ) 1992 ]; 1993 this.historyIndex += 1; 1994 this.historySubscribers.forEach((listener) => listener()); 1995 } 1996 _replaceHistory() { 1997 this.history[this.historyIndex] = this._getWidgetIds().map( 1998 (widgetId) => this.getWidget(widgetId) 1999 ); 2000 } 2001 _handleSettingChange() { 2002 if (this.locked) { 2003 return; 2004 } 2005 const prevWidgets = this.getWidgets(); 2006 this._pushHistory(); 2007 this._emit(prevWidgets, this.getWidgets()); 2008 } 2009 _handleAllSettingsChange(setting) { 2010 if (this.locked) { 2011 return; 2012 } 2013 if (!setting.id.startsWith("widget_")) { 2014 return; 2015 } 2016 const widgetId = settingIdToWidgetId(setting.id); 2017 if (!this.setting.get().includes(widgetId)) { 2018 return; 2019 } 2020 const prevWidgets = this.getWidgets(); 2021 this._pushHistory(); 2022 this._emit(prevWidgets, this.getWidgets()); 2023 } 2024 _createWidget(widget) { 2025 const widgetModel = wp.customize.Widgets.availableWidgets.findWhere({ 2026 id_base: widget.idBase 2027 }); 2028 let number = widget.number; 2029 if (widgetModel.get("is_multi") && !number) { 2030 widgetModel.set( 2031 "multi_number", 2032 widgetModel.get("multi_number") + 1 2033 ); 2034 number = widgetModel.get("multi_number"); 2035 } 2036 const settingId = number ? `widget_$widget.idBase}[$number}]` : `widget_$widget.idBase}`; 2037 const settingArgs = { 2038 transport: wp.customize.Widgets.data.selectiveRefreshableWidgets[widgetModel.get("id_base")] ? "postMessage" : "refresh", 2039 previewer: this.setting.previewer 2040 }; 2041 const setting = this.api.create( 2042 settingId, 2043 settingId, 2044 "", 2045 settingArgs 2046 ); 2047 setting.set(widget.instance); 2048 const widgetId = settingIdToWidgetId(settingId); 2049 return widgetId; 2050 } 2051 _removeWidget(widget) { 2052 const settingId = widgetIdToSettingId(widget.id); 2053 const setting = this.api(settingId); 2054 if (setting) { 2055 const instance = setting.get(); 2056 this.widgetsCache.delete(instance); 2057 } 2058 this.api.remove(settingId); 2059 } 2060 _updateWidget(widget) { 2061 const prevWidget = this.getWidget(widget.id); 2062 if (prevWidget === widget) { 2063 return widget.id; 2064 } 2065 if (prevWidget.idBase && widget.idBase && prevWidget.idBase === widget.idBase) { 2066 const settingId = widgetIdToSettingId(widget.id); 2067 this.api(settingId).set(widget.instance); 2068 return widget.id; 2069 } 2070 this._removeWidget(widget); 2071 return this._createWidget(widget); 2072 } 2073 getWidget(widgetId) { 2074 if (!widgetId) { 2075 return null; 2076 } 2077 const { idBase, number } = parseWidgetId(widgetId); 2078 const settingId = widgetIdToSettingId(widgetId); 2079 const setting = this.api(settingId); 2080 if (!setting) { 2081 return null; 2082 } 2083 const instance = setting.get(); 2084 if (this.widgetsCache.has(instance)) { 2085 return this.widgetsCache.get(instance); 2086 } 2087 const widget = { 2088 id: widgetId, 2089 idBase, 2090 number, 2091 instance 2092 }; 2093 this.widgetsCache.set(instance, widget); 2094 return widget; 2095 } 2096 _updateWidgets(nextWidgets) { 2097 this.locked = true; 2098 const addedWidgetIds = []; 2099 const nextWidgetIds = nextWidgets.map((nextWidget) => { 2100 if (nextWidget.id && this.getWidget(nextWidget.id)) { 2101 addedWidgetIds.push(null); 2102 return this._updateWidget(nextWidget); 2103 } 2104 const widgetId = this._createWidget(nextWidget); 2105 addedWidgetIds.push(widgetId); 2106 return widgetId; 2107 }); 2108 const deletedWidgets = this.getWidgets().filter( 2109 (widget) => !nextWidgetIds.includes(widget.id) 2110 ); 2111 deletedWidgets.forEach((widget) => this._removeWidget(widget)); 2112 this.setting.set(nextWidgetIds); 2113 this.locked = false; 2114 return addedWidgetIds; 2115 } 2116 setWidgets(nextWidgets) { 2117 const addedWidgetIds = this._updateWidgets(nextWidgets); 2118 this._debounceSetHistory(); 2119 return addedWidgetIds; 2120 } 2121 /** 2122 * Undo/Redo related features 2123 */ 2124 hasUndo() { 2125 return this.historyIndex > 0; 2126 } 2127 hasRedo() { 2128 return this.historyIndex < this.history.length - 1; 2129 } 2130 _seek(historyIndex) { 2131 const currentWidgets = this.getWidgets(); 2132 this.historyIndex = historyIndex; 2133 const widgets = this.history[this.historyIndex]; 2134 this._updateWidgets(widgets); 2135 this._emit(currentWidgets, this.getWidgets()); 2136 this.historySubscribers.forEach((listener) => listener()); 2137 this._debounceSetHistory.cancel(); 2138 } 2139 undo() { 2140 if (!this.hasUndo()) { 2141 return; 2142 } 2143 this._seek(this.historyIndex - 1); 2144 } 2145 redo() { 2146 if (!this.hasRedo()) { 2147 return; 2148 } 2149 this._seek(this.historyIndex + 1); 2150 } 2151 subscribeHistory(listener) { 2152 this.historySubscribers.add(listener); 2153 return () => { 2154 this.historySubscribers.delete(listener); 2155 }; 2156 } 2157 save() { 2158 this.api.previewer.save(); 2159 } 2160 }; 2161 2162 // packages/customize-widgets/build-module/controls/inserter-outer-section.js 2163 var import_keycodes5 = __toESM(require_keycodes()); 2164 var import_dom = __toESM(require_dom()); 2165 var import_data14 = __toESM(require_data()); 2166 function getInserterOuterSection() { 2167 const { 2168 wp: { customize } 2169 } = window; 2170 const OuterSection = customize.OuterSection; 2171 customize.OuterSection = class extends OuterSection { 2172 onChangeExpanded(expanded, args) { 2173 if (expanded) { 2174 customize.section.each((section) => { 2175 if (section.params.type === "outer" && section.id !== this.id) { 2176 if (section.expanded()) { 2177 section.collapse(); 2178 } 2179 } 2180 }); 2181 } 2182 return super.onChangeExpanded(expanded, args); 2183 } 2184 }; 2185 customize.sectionConstructor.outer = customize.OuterSection; 2186 return class InserterOuterSection extends customize.OuterSection { 2187 constructor(...args) { 2188 super(...args); 2189 this.params.type = "outer"; 2190 this.activeElementBeforeExpanded = null; 2191 const ownerWindow = this.contentContainer[0].ownerDocument.defaultView; 2192 ownerWindow.addEventListener( 2193 "keydown", 2194 (event) => { 2195 if (this.expanded() && (event.keyCode === import_keycodes5.ESCAPE || event.code === "Escape") && !event.defaultPrevented) { 2196 event.preventDefault(); 2197 event.stopPropagation(); 2198 (0, import_data14.dispatch)(store).setIsInserterOpened( 2199 false 2200 ); 2201 } 2202 }, 2203 // Use capture mode to make this run before other event listeners. 2204 true 2205 ); 2206 this.contentContainer.addClass("widgets-inserter"); 2207 this.isFromInternalAction = false; 2208 this.expanded.bind(() => { 2209 if (!this.isFromInternalAction) { 2210 (0, import_data14.dispatch)(store).setIsInserterOpened( 2211 this.expanded() 2212 ); 2213 } 2214 this.isFromInternalAction = false; 2215 }); 2216 } 2217 open() { 2218 if (!this.expanded()) { 2219 const contentContainer = this.contentContainer[0]; 2220 this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement; 2221 this.isFromInternalAction = true; 2222 this.expand({ 2223 completeCallback() { 2224 const searchBox = import_dom.focus.tabbable.find(contentContainer)[1]; 2225 if (searchBox) { 2226 searchBox.focus(); 2227 } 2228 } 2229 }); 2230 } 2231 } 2232 close() { 2233 if (this.expanded()) { 2234 const contentContainer = this.contentContainer[0]; 2235 const activeElement = contentContainer.ownerDocument.activeElement; 2236 this.isFromInternalAction = true; 2237 this.collapse({ 2238 completeCallback() { 2239 if (contentContainer.contains(activeElement)) { 2240 if (this.activeElementBeforeExpanded) { 2241 this.activeElementBeforeExpanded.focus(); 2242 } 2243 } 2244 } 2245 }); 2246 } 2247 } 2248 }; 2249 } 2250 2251 // packages/customize-widgets/build-module/controls/sidebar-control.js 2252 var getInserterId = (controlId) => `widgets-inserter-$controlId}`; 2253 function getSidebarControl() { 2254 const { 2255 wp: { customize } 2256 } = window; 2257 return class SidebarControl extends customize.Control { 2258 constructor(...args) { 2259 super(...args); 2260 this.subscribers = /* @__PURE__ */ new Set(); 2261 } 2262 ready() { 2263 const InserterOuterSection = getInserterOuterSection(); 2264 this.inserter = new InserterOuterSection( 2265 getInserterId(this.id), 2266 {} 2267 ); 2268 customize.section.add(this.inserter); 2269 this.sectionInstance = customize.section(this.section()); 2270 this.inspector = this.sectionInstance.inspector; 2271 this.sidebarAdapter = new SidebarAdapter(this.setting, customize); 2272 } 2273 subscribe(callback) { 2274 this.subscribers.add(callback); 2275 return () => { 2276 this.subscribers.delete(callback); 2277 }; 2278 } 2279 onChangeSectionExpanded(expanded, args) { 2280 if (!args.unchanged) { 2281 if (!expanded) { 2282 (0, import_data15.dispatch)(store).setIsInserterOpened( 2283 false 2284 ); 2285 } 2286 this.subscribers.forEach( 2287 (subscriber) => subscriber(expanded, args) 2288 ); 2289 } 2290 } 2291 }; 2292 } 2293 2294 // packages/customize-widgets/build-module/filters/move-to-sidebar.js 2295 var import_block_editor10 = __toESM(require_block_editor()); 2296 var import_compose4 = __toESM(require_compose()); 2297 var import_data16 = __toESM(require_data()); 2298 var import_hooks2 = __toESM(require_hooks()); 2299 var import_widgets4 = __toESM(require_widgets()); 2300 var import_jsx_runtime22 = __toESM(require_jsx_runtime()); 2301 var withMoveToSidebarToolbarItem = (0, import_compose4.createHigherOrderComponent)( 2302 (BlockEdit) => (props) => { 2303 let widgetId = (0, import_widgets4.getWidgetIdFromBlock)(props); 2304 const sidebarControls = useSidebarControls(); 2305 const activeSidebarControl = useActiveSidebarControl(); 2306 const hasMultipleSidebars = sidebarControls?.length > 1; 2307 const blockName = props.name; 2308 const clientId = props.clientId; 2309 const canInsertBlockInSidebar = (0, import_data16.useSelect)( 2310 (select) => { 2311 return select(import_block_editor10.store).canInsertBlockType( 2312 blockName, 2313 "" 2314 ); 2315 }, 2316 [blockName] 2317 ); 2318 const block = (0, import_data16.useSelect)( 2319 (select) => select(import_block_editor10.store).getBlock(clientId), 2320 [clientId] 2321 ); 2322 const { removeBlock } = (0, import_data16.useDispatch)(import_block_editor10.store); 2323 const [, focusWidget] = useFocusControl(); 2324 function moveToSidebar(sidebarControlId) { 2325 const newSidebarControl = sidebarControls.find( 2326 (sidebarControl) => sidebarControl.id === sidebarControlId 2327 ); 2328 if (widgetId) { 2329 const oldSetting = activeSidebarControl.setting; 2330 const newSetting = newSidebarControl.setting; 2331 oldSetting(oldSetting().filter((id) => id !== widgetId)); 2332 newSetting([...newSetting(), widgetId]); 2333 } else { 2334 const sidebarAdapter = newSidebarControl.sidebarAdapter; 2335 removeBlock(clientId); 2336 const addedWidgetIds = sidebarAdapter.setWidgets([ 2337 ...sidebarAdapter.getWidgets(), 2338 blockToWidget(block) 2339 ]); 2340 widgetId = addedWidgetIds.reverse().find((id) => !!id); 2341 } 2342 focusWidget(widgetId); 2343 } 2344 return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [ 2345 /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BlockEdit, { ...props }, "edit"), 2346 hasMultipleSidebars && canInsertBlockInSidebar && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_block_editor10.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)( 2347 import_widgets4.MoveToWidgetArea, 2348 { 2349 widgetAreas: sidebarControls.map( 2350 (sidebarControl) => ({ 2351 id: sidebarControl.id, 2352 name: sidebarControl.params.label, 2353 description: sidebarControl.params.description 2354 }) 2355 ), 2356 currentWidgetAreaId: activeSidebarControl?.id, 2357 onSelect: moveToSidebar 2358 } 2359 ) }) 2360 ] }); 2361 }, 2362 "withMoveToSidebarToolbarItem" 2363 ); 2364 (0, import_hooks2.addFilter)( 2365 "editor.BlockEdit", 2366 "core/customize-widgets/block-edit", 2367 withMoveToSidebarToolbarItem 2368 ); 2369 2370 // packages/customize-widgets/build-module/filters/replace-media-upload.js 2371 var import_hooks3 = __toESM(require_hooks()); 2372 var import_media_utils2 = __toESM(require_media_utils()); 2373 var replaceMediaUpload = () => import_media_utils2.MediaUpload; 2374 (0, import_hooks3.addFilter)( 2375 "editor.MediaUpload", 2376 "core/edit-widgets/replace-media-upload", 2377 replaceMediaUpload 2378 ); 2379 2380 // packages/customize-widgets/build-module/filters/wide-widget-display.js 2381 var import_compose5 = __toESM(require_compose()); 2382 var import_hooks4 = __toESM(require_hooks()); 2383 var import_jsx_runtime23 = __toESM(require_jsx_runtime()); 2384 var { wp: wp2 } = window; 2385 var withWideWidgetDisplay = (0, import_compose5.createHigherOrderComponent)( 2386 (BlockEdit) => (props) => { 2387 const { idBase } = props.attributes; 2388 const isWide = wp2.customize.Widgets.data.availableWidgets.find( 2389 (widget) => widget.id_base === idBase 2390 )?.is_wide ?? false; 2391 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BlockEdit, { ...props, isWide }, "edit"); 2392 }, 2393 "withWideWidgetDisplay" 2394 ); 2395 (0, import_hooks4.addFilter)( 2396 "editor.BlockEdit", 2397 "core/customize-widgets/wide-widget-display", 2398 withWideWidgetDisplay 2399 ); 2400 2401 // packages/customize-widgets/build-module/index.js 2402 var import_jsx_runtime24 = __toESM(require_jsx_runtime()); 2403 var { wp: wp3 } = window; 2404 var DISABLED_BLOCKS = [ 2405 "core/more", 2406 "core/block", 2407 "core/freeform", 2408 "core/template-part" 2409 ]; 2410 function initialize(editorName, blockEditorSettings) { 2411 (0, import_data17.dispatch)(import_preferences4.store).setDefaults("core/customize-widgets", { 2412 fixedToolbar: false, 2413 welcomeGuide: true 2414 }); 2415 (0, import_data17.dispatch)(import_blocks2.store).reapplyBlockTypeFilters(); 2416 const coreBlocks = (0, import_block_library2.__experimentalGetCoreBlocks)().filter((block) => { 2417 return !(DISABLED_BLOCKS.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")); 2418 }); 2419 (0, import_block_library2.registerCoreBlocks)(coreBlocks); 2420 (0, import_widgets5.registerLegacyWidgetBlock)(); 2421 if (false) { 2422 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({ 2423 enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS 2424 }); 2425 } 2426 (0, import_widgets5.registerLegacyWidgetVariations)(blockEditorSettings); 2427 (0, import_widgets5.registerWidgetGroupBlock)(); 2428 (0, import_blocks2.setFreeformContentHandlerName)("core/html"); 2429 const SidebarControl = getSidebarControl(blockEditorSettings); 2430 wp3.customize.sectionConstructor.sidebar = getSidebarSection(); 2431 wp3.customize.controlConstructor.sidebar_block_editor = SidebarControl; 2432 const container = document.createElement("div"); 2433 document.body.appendChild(container); 2434 wp3.customize.bind("ready", () => { 2435 const sidebarControls = []; 2436 wp3.customize.control.each((control) => { 2437 if (control instanceof SidebarControl) { 2438 sidebarControls.push(control); 2439 } 2440 }); 2441 (0, import_element17.createRoot)(container).render( 2442 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_element17.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 2443 CustomizeWidgets, 2444 { 2445 api: wp3.customize, 2446 sidebarControls, 2447 blockEditorSettings 2448 } 2449 ) }) 2450 ); 2451 }); 2452 } 2453 return __toCommonJS(index_exports); 2454 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Apr 15 08:20:10 2026 | Cross-referenced by PHPXref |