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