[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ // The require scope 4 /******/ var __webpack_require__ = {}; 5 /******/ 6 /************************************************************************/ 7 /******/ /* webpack/runtime/define property getters */ 8 /******/ (() => { 9 /******/ // define getter functions for harmony exports 10 /******/ __webpack_require__.d = (exports, definition) => { 11 /******/ for(var key in definition) { 12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14 /******/ } 15 /******/ } 16 /******/ }; 17 /******/ })(); 18 /******/ 19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 20 /******/ (() => { 21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 22 /******/ })(); 23 /******/ 24 /******/ /* webpack/runtime/make namespace object */ 25 /******/ (() => { 26 /******/ // define __esModule on exports 27 /******/ __webpack_require__.r = (exports) => { 28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 30 /******/ } 31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 32 /******/ }; 33 /******/ })(); 34 /******/ 35 /************************************************************************/ 36 var __webpack_exports__ = {}; 37 // ESM COMPAT FLAG 38 __webpack_require__.r(__webpack_exports__); 39 40 // EXPORTS 41 __webpack_require__.d(__webpack_exports__, { 42 ALT: () => (/* binding */ ALT), 43 BACKSPACE: () => (/* binding */ BACKSPACE), 44 COMMAND: () => (/* binding */ COMMAND), 45 CTRL: () => (/* binding */ CTRL), 46 DELETE: () => (/* binding */ DELETE), 47 DOWN: () => (/* binding */ DOWN), 48 END: () => (/* binding */ END), 49 ENTER: () => (/* binding */ ENTER), 50 ESCAPE: () => (/* binding */ ESCAPE), 51 F10: () => (/* binding */ F10), 52 HOME: () => (/* binding */ HOME), 53 LEFT: () => (/* binding */ LEFT), 54 PAGEDOWN: () => (/* binding */ PAGEDOWN), 55 PAGEUP: () => (/* binding */ PAGEUP), 56 RIGHT: () => (/* binding */ RIGHT), 57 SHIFT: () => (/* binding */ SHIFT), 58 SPACE: () => (/* binding */ SPACE), 59 TAB: () => (/* binding */ TAB), 60 UP: () => (/* binding */ UP), 61 ZERO: () => (/* binding */ ZERO), 62 displayShortcut: () => (/* binding */ displayShortcut), 63 displayShortcutList: () => (/* binding */ displayShortcutList), 64 isAppleOS: () => (/* reexport */ isAppleOS), 65 isKeyboardEvent: () => (/* binding */ isKeyboardEvent), 66 modifiers: () => (/* binding */ modifiers), 67 rawShortcut: () => (/* binding */ rawShortcut), 68 shortcutAriaLabel: () => (/* binding */ shortcutAriaLabel) 69 }); 70 71 ;// external ["wp","i18n"] 72 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 73 ;// ./node_modules/@wordpress/keycodes/build-module/platform.js 74 /** 75 * Return true if platform is MacOS. 76 * 77 * @param {Window?} _window window object by default; used for DI testing. 78 * 79 * @return {boolean} True if MacOS; false otherwise. 80 */ 81 function isAppleOS(_window = null) { 82 if (!_window) { 83 if (typeof window === 'undefined') { 84 return false; 85 } 86 _window = window; 87 } 88 const { 89 platform 90 } = _window.navigator; 91 return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform); 92 } 93 94 ;// ./node_modules/@wordpress/keycodes/build-module/index.js 95 /* wp:polyfill */ 96 /** 97 * Note: The order of the modifier keys in many of the [foo]Shortcut() 98 * functions in this file are intentional and should not be changed. They're 99 * designed to fit with the standard menu keyboard shortcuts shown in the 100 * user's platform. 101 * 102 * For example, on MacOS menu shortcuts will place Shift before Command, but 103 * on Windows Control will usually come first. So don't provide your own 104 * shortcut combos directly to keyboardShortcut(). 105 */ 106 107 /** 108 * WordPress dependencies 109 */ 110 111 112 /** 113 * Internal dependencies 114 */ 115 116 117 /** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */ 118 119 /** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */ 120 121 /** 122 * An object of handler functions for each of the possible modifier 123 * combinations. A handler will return a value for a given key. 124 * 125 * @template T 126 * 127 * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler 128 */ 129 130 /** 131 * @template T 132 * 133 * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler 134 */ 135 /** @typedef {(event: import('react').KeyboardEvent<HTMLElement> | KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */ 136 137 /** @typedef {( isApple: () => boolean ) => WPModifierPart[]} WPModifier */ 138 139 /** 140 * Keycode for BACKSPACE key. 141 */ 142 const BACKSPACE = 8; 143 144 /** 145 * Keycode for TAB key. 146 */ 147 const TAB = 9; 148 149 /** 150 * Keycode for ENTER key. 151 */ 152 const ENTER = 13; 153 154 /** 155 * Keycode for ESCAPE key. 156 */ 157 const ESCAPE = 27; 158 159 /** 160 * Keycode for SPACE key. 161 */ 162 const SPACE = 32; 163 164 /** 165 * Keycode for PAGEUP key. 166 */ 167 const PAGEUP = 33; 168 169 /** 170 * Keycode for PAGEDOWN key. 171 */ 172 const PAGEDOWN = 34; 173 174 /** 175 * Keycode for END key. 176 */ 177 const END = 35; 178 179 /** 180 * Keycode for HOME key. 181 */ 182 const HOME = 36; 183 184 /** 185 * Keycode for LEFT key. 186 */ 187 const LEFT = 37; 188 189 /** 190 * Keycode for UP key. 191 */ 192 const UP = 38; 193 194 /** 195 * Keycode for RIGHT key. 196 */ 197 const RIGHT = 39; 198 199 /** 200 * Keycode for DOWN key. 201 */ 202 const DOWN = 40; 203 204 /** 205 * Keycode for DELETE key. 206 */ 207 const DELETE = 46; 208 209 /** 210 * Keycode for F10 key. 211 */ 212 const F10 = 121; 213 214 /** 215 * Keycode for ALT key. 216 */ 217 const ALT = 'alt'; 218 219 /** 220 * Keycode for CTRL key. 221 */ 222 const CTRL = 'ctrl'; 223 224 /** 225 * Keycode for COMMAND/META key. 226 */ 227 const COMMAND = 'meta'; 228 229 /** 230 * Keycode for SHIFT key. 231 */ 232 const SHIFT = 'shift'; 233 234 /** 235 * Keycode for ZERO key. 236 */ 237 const ZERO = 48; 238 239 240 /** 241 * Capitalise the first character of a string. 242 * @param {string} string String to capitalise. 243 * @return {string} Capitalised string. 244 */ 245 function capitaliseFirstCharacter(string) { 246 return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1); 247 } 248 249 /** 250 * Map the values of an object with a specified callback and return the result object. 251 * 252 * @template {{ [s: string]: any; } | ArrayLike<any>} T 253 * 254 * @param {T} object Object to map values of. 255 * @param {( value: any ) => any} mapFn Mapping function 256 * 257 * @return {any} Active modifier constants. 258 */ 259 function mapValues(object, mapFn) { 260 return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, mapFn(value)])); 261 } 262 263 /** 264 * Object that contains functions that return the available modifier 265 * depending on platform. 266 * 267 * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>} 268 */ 269 const modifiers = { 270 primary: _isApple => _isApple() ? [COMMAND] : [CTRL], 271 primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT], 272 primaryAlt: _isApple => _isApple() ? [ALT, COMMAND] : [CTRL, ALT], 273 secondary: _isApple => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT], 274 access: _isApple => _isApple() ? [CTRL, ALT] : [SHIFT, ALT], 275 ctrl: () => [CTRL], 276 alt: () => [ALT], 277 ctrlShift: () => [CTRL, SHIFT], 278 shift: () => [SHIFT], 279 shiftAlt: () => [SHIFT, ALT], 280 undefined: () => [] 281 }; 282 283 /** 284 * An object that contains functions to get raw shortcuts. 285 * 286 * These are intended for user with the KeyboardShortcuts. 287 * 288 * @example 289 * ```js 290 * // Assuming macOS: 291 * rawShortcut.primary( 'm' ) 292 * // "meta+m"" 293 * ``` 294 * 295 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw 296 * shortcuts. 297 */ 298 const rawShortcut = /* @__PURE__ */ 299 mapValues(modifiers, (/** @type {WPModifier} */modifier) => { 300 return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => { 301 return [...modifier(_isApple), character.toLowerCase()].join('+'); 302 }; 303 }); 304 305 /** 306 * Return an array of the parts of a keyboard shortcut chord for display. 307 * 308 * @example 309 * ```js 310 * // Assuming macOS: 311 * displayShortcutList.primary( 'm' ); 312 * // [ "⌘", "M" ] 313 * ``` 314 * 315 * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to 316 * shortcut sequences. 317 */ 318 const displayShortcutList = /* @__PURE__ */ 319 mapValues(modifiers, (/** @type {WPModifier} */modifier) => { 320 return /** @type {WPKeyHandler<string[]>} */(character, _isApple = isAppleOS) => { 321 const isApple = _isApple(); 322 const replacementKeyMap = { 323 [ALT]: isApple ? '⌥' : 'Alt', 324 [CTRL]: isApple ? '⌃' : 'Ctrl', 325 // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character. 326 [COMMAND]: '⌘', 327 [SHIFT]: isApple ? '⇧' : 'Shift' 328 }; 329 const modifierKeys = modifier(_isApple).reduce((accumulator, key) => { 330 var _replacementKeyMap$ke; 331 const replacementKey = (_replacementKeyMap$ke = replacementKeyMap[key]) !== null && _replacementKeyMap$ke !== void 0 ? _replacementKeyMap$ke : key; 332 // If on the Mac, adhere to platform convention and don't show plus between keys. 333 if (isApple) { 334 return [...accumulator, replacementKey]; 335 } 336 return [...accumulator, replacementKey, '+']; 337 }, /** @type {string[]} */[]); 338 return [...modifierKeys, capitaliseFirstCharacter(character)]; 339 }; 340 }); 341 342 /** 343 * An object that contains functions to display shortcuts. 344 * 345 * @example 346 * ```js 347 * // Assuming macOS: 348 * displayShortcut.primary( 'm' ); 349 * // "⌘M" 350 * ``` 351 * 352 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to 353 * display shortcuts. 354 */ 355 const displayShortcut = /* @__PURE__ */ 356 mapValues(displayShortcutList, (/** @type {WPKeyHandler<string[]>} */shortcutList) => { 357 return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => shortcutList(character, _isApple).join(''); 358 }); 359 360 /** 361 * An object that contains functions to return an aria label for a keyboard 362 * shortcut. 363 * 364 * @example 365 * ```js 366 * // Assuming macOS: 367 * shortcutAriaLabel.primary( '.' ); 368 * // "Command + Period" 369 * ``` 370 * 371 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to 372 * shortcut ARIA labels. 373 */ 374 const shortcutAriaLabel = /* @__PURE__ */ 375 mapValues(modifiers, (/** @type {WPModifier} */modifier) => { 376 return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => { 377 const isApple = _isApple(); 378 /** @type {Record<string,string>} */ 379 const replacementKeyMap = { 380 [SHIFT]: 'Shift', 381 [COMMAND]: isApple ? 'Command' : 'Control', 382 [CTRL]: 'Control', 383 [ALT]: isApple ? 'Option' : 'Alt', 384 /* translators: comma as in the character ',' */ 385 ',': (0,external_wp_i18n_namespaceObject.__)('Comma'), 386 /* translators: period as in the character '.' */ 387 '.': (0,external_wp_i18n_namespaceObject.__)('Period'), 388 /* translators: backtick as in the character '`' */ 389 '`': (0,external_wp_i18n_namespaceObject.__)('Backtick'), 390 /* translators: tilde as in the character '~' */ 391 '~': (0,external_wp_i18n_namespaceObject.__)('Tilde') 392 }; 393 return [...modifier(_isApple), character].map(key => { 394 var _replacementKeyMap$ke2; 395 return capitaliseFirstCharacter((_replacementKeyMap$ke2 = replacementKeyMap[key]) !== null && _replacementKeyMap$ke2 !== void 0 ? _replacementKeyMap$ke2 : key); 396 }).join(isApple ? ' ' : ' + '); 397 }; 398 }); 399 400 /** 401 * From a given KeyboardEvent, returns an array of active modifier constants for 402 * the event. 403 * 404 * @param {import('react').KeyboardEvent<HTMLElement> | KeyboardEvent} event Keyboard event. 405 * 406 * @return {Array<WPModifierPart>} Active modifier constants. 407 */ 408 function getEventModifiers(event) { 409 return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[(/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ 410 `$key}Key`)]); 411 } 412 413 /** 414 * An object that contains functions to check if a keyboard event matches a 415 * predefined shortcut combination. 416 * 417 * @example 418 * ```js 419 * // Assuming an event for ⌘M key press: 420 * isKeyboardEvent.primary( event, 'm' ); 421 * // true 422 * ``` 423 * 424 * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions 425 * to match events. 426 */ 427 const isKeyboardEvent = /* @__PURE__ */ 428 mapValues(modifiers, (/** @type {WPModifier} */getModifiers) => { 429 return /** @type {WPEventKeyHandler} */(event, character, _isApple = isAppleOS) => { 430 const mods = getModifiers(_isApple); 431 const eventMods = getEventModifiers(event); 432 /** @type {Record<string,string>} */ 433 const replacementWithShiftKeyMap = { 434 Comma: ',', 435 Backslash: '\\', 436 // Windows returns `\` for both IntlRo and IntlYen. 437 IntlRo: '\\', 438 IntlYen: '\\' 439 }; 440 const modsDiff = mods.filter(mod => !eventMods.includes(mod)); 441 const eventModsDiff = eventMods.filter(mod => !mods.includes(mod)); 442 if (modsDiff.length > 0 || eventModsDiff.length > 0) { 443 return false; 444 } 445 let key = event.key.toLowerCase(); 446 if (!character) { 447 return mods.includes(/** @type {WPModifierPart} */key); 448 } 449 if (event.altKey && character.length === 1) { 450 key = String.fromCharCode(event.keyCode).toLowerCase(); 451 } 452 453 // `event.key` returns the value of the key pressed, taking into the state of 454 // modifier keys such as `Shift`. If the shift key is pressed, a different 455 // value may be returned depending on the keyboard layout. It is necessary to 456 // convert to the physical key value that don't take into account keyboard 457 // layout or modifier key state. 458 if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) { 459 key = replacementWithShiftKeyMap[event.code]; 460 } 461 462 // For backwards compatibility. 463 if (character === 'del') { 464 character = 'delete'; 465 } 466 return key === character.toLowerCase(); 467 }; 468 }); 469 470 (window.wp = window.wp || {}).keycodes = __webpack_exports__; 471 /******/ })() 472 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Tue Feb 18 08:20:02 2025 | Cross-referenced by PHPXref |