| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 (function() { 2 "use strict"; 3 var wp; 4 (wp ||= {}).keycodes = (() => { 5 var __create = Object.create; 6 var __defProp = Object.defineProperty; 7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 8 var __getOwnPropNames = Object.getOwnPropertyNames; 9 var __getProtoOf = Object.getPrototypeOf; 10 var __hasOwnProp = Object.prototype.hasOwnProperty; 11 var __commonJS = (cb, mod) => function __require() { 12 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 13 }; 14 var __export = (target, all) => { 15 for (var name in all) 16 __defProp(target, name, { get: all[name], enumerable: true }); 17 }; 18 var __copyProps = (to, from, except, desc) => { 19 if (from && typeof from === "object" || typeof from === "function") { 20 for (let key of __getOwnPropNames(from)) 21 if (!__hasOwnProp.call(to, key) && key !== except) 22 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 23 } 24 return to; 25 }; 26 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 27 // If the importer is in node compatibility mode or this is not an ESM 28 // file that has been converted to a CommonJS file using a Babel- 29 // compatible transform (i.e. "__esModule" has not been set), then set 30 // "default" to the CommonJS "module.exports" for node compatibility. 31 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 32 mod 33 )); 34 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 35 36 // package-external:@wordpress/i18n 37 var require_i18n = __commonJS({ 38 "package-external:@wordpress/i18n"(exports, module) { 39 module.exports = window.wp.i18n; 40 } 41 }); 42 43 // packages/keycodes/build-module/index.mjs 44 var index_exports = {}; 45 __export(index_exports, { 46 ALT: () => ALT, 47 BACKSPACE: () => BACKSPACE, 48 COMMAND: () => COMMAND, 49 CTRL: () => CTRL, 50 DELETE: () => DELETE, 51 DOWN: () => DOWN, 52 END: () => END, 53 ENTER: () => ENTER, 54 ESCAPE: () => ESCAPE, 55 F10: () => F10, 56 HOME: () => HOME, 57 LEFT: () => LEFT, 58 PAGEDOWN: () => PAGEDOWN, 59 PAGEUP: () => PAGEUP, 60 RIGHT: () => RIGHT, 61 SHIFT: () => SHIFT, 62 SPACE: () => SPACE, 63 TAB: () => TAB, 64 UP: () => UP, 65 ZERO: () => ZERO, 66 ariaKeyShortcut: () => ariaKeyShortcut, 67 displayShortcut: () => displayShortcut, 68 displayShortcutList: () => displayShortcutList, 69 isAppleOS: () => isAppleOS, 70 isKeyboardEvent: () => isKeyboardEvent, 71 keyboardShortcut: () => keyboardShortcut, 72 modifiers: () => modifiers, 73 rawShortcut: () => rawShortcut, 74 shortcutAriaLabel: () => shortcutAriaLabel, 75 withIgnoreIMEEvents: () => withIgnoreIMEEvents 76 }); 77 var import_i18n = __toESM(require_i18n(), 1); 78 79 // packages/keycodes/build-module/platform.mjs 80 function isAppleOS(_window) { 81 if (!_window) { 82 if (typeof window === "undefined") { 83 return false; 84 } 85 _window = window; 86 } 87 const { platform } = _window.navigator; 88 return platform.indexOf("Mac") !== -1 || ["iPad", "iPhone"].includes(platform); 89 } 90 91 // packages/keycodes/build-module/with-ignore-ime-events.mjs 92 function withIgnoreIMEEvents(handler) { 93 return (event) => { 94 const { isComposing } = "nativeEvent" in event ? event.nativeEvent : event; 95 if (isComposing || // Workaround for Mac Safari where the final Enter/Backspace of an IME composition 96 // is `isComposing=false`, even though it's technically still part of the composition. 97 // These can only be detected by keyCode. 98 event.keyCode === 229) { 99 return; 100 } 101 handler(event); 102 }; 103 } 104 105 // packages/keycodes/build-module/index.mjs 106 var BACKSPACE = 8; 107 var TAB = 9; 108 var ENTER = 13; 109 var ESCAPE = 27; 110 var SPACE = 32; 111 var PAGEUP = 33; 112 var PAGEDOWN = 34; 113 var END = 35; 114 var HOME = 36; 115 var LEFT = 37; 116 var UP = 38; 117 var RIGHT = 39; 118 var DOWN = 40; 119 var DELETE = 46; 120 var F10 = 121; 121 var ALT = "alt"; 122 var CTRL = "ctrl"; 123 var COMMAND = "meta"; 124 var SHIFT = "shift"; 125 var ZERO = 48; 126 function capitaliseFirstCharacter(string) { 127 return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1); 128 } 129 function mapValues(object, mapFn) { 130 return Object.fromEntries( 131 Object.entries(object).map(([key, value]) => [ 132 key, 133 mapFn(value) 134 ]) 135 ); 136 } 137 var modifiers = { 138 primary: (_isApple) => _isApple() ? [COMMAND] : [CTRL], 139 primaryShift: (_isApple) => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT], 140 primaryAlt: (_isApple) => _isApple() ? [ALT, COMMAND] : [CTRL, ALT], 141 secondary: (_isApple) => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT], 142 access: (_isApple) => _isApple() ? [CTRL, ALT] : [SHIFT, ALT], 143 ctrl: () => [CTRL], 144 alt: () => [ALT], 145 ctrlShift: () => [CTRL, SHIFT], 146 shift: () => [SHIFT], 147 shiftAlt: () => [SHIFT, ALT], 148 undefined: () => [] 149 }; 150 var rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => { 151 return (character, _isApple = isAppleOS) => { 152 return [...modifier(_isApple), character.toLowerCase()].join( 153 "+" 154 ); 155 }; 156 }); 157 var ariaKeyShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => { 158 return (character, _isApple = isAppleOS) => { 159 return [ 160 ...modifier(_isApple).map((key) => key === CTRL ? "Control" : key).map((key) => capitaliseFirstCharacter(key)), 161 capitaliseFirstCharacter(character) 162 ].join("+"); 163 }; 164 }); 165 var displayShortcutList = /* @__PURE__ */ mapValues( 166 modifiers, 167 (modifier) => { 168 return (character, _isApple = isAppleOS) => { 169 const isApple = _isApple(); 170 const replacementKeyMap = { 171 [ALT]: isApple ? "\u2325" : "Alt", 172 [CTRL]: isApple ? "\u2303" : "Ctrl", 173 // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character. 174 [COMMAND]: "\u2318", 175 [SHIFT]: isApple ? "\u21E7" : "Shift" 176 }; 177 const modifierKeys = modifier(_isApple).reduce( 178 (accumulator, key) => { 179 const replacementKey = replacementKeyMap[key] ?? key; 180 if (isApple) { 181 return [...accumulator, replacementKey]; 182 } 183 return [...accumulator, replacementKey, "+"]; 184 }, 185 [] 186 ); 187 return [ 188 ...modifierKeys, 189 capitaliseFirstCharacter(character) 190 ]; 191 }; 192 } 193 ); 194 var displayShortcut = /* @__PURE__ */ mapValues( 195 displayShortcutList, 196 (shortcutList) => { 197 return (character, _isApple = isAppleOS) => shortcutList(character, _isApple).join(""); 198 } 199 ); 200 var shortcutAriaLabel = /* @__PURE__ */ mapValues(modifiers, (modifier) => { 201 return (character, _isApple = isAppleOS) => { 202 const isApple = _isApple(); 203 const replacementKeyMap = { 204 [SHIFT]: "Shift", 205 [COMMAND]: isApple ? "Command" : "Control", 206 [CTRL]: "Control", 207 [ALT]: isApple ? "Option" : "Alt", 208 /* translators: comma as in the character ',' */ 209 ",": (0, import_i18n.__)("Comma"), 210 /* translators: period as in the character '.' */ 211 ".": (0, import_i18n.__)("Period"), 212 /* translators: backtick as in the character '`' */ 213 "`": (0, import_i18n.__)("Backtick"), 214 /* translators: tilde as in the character '~' */ 215 "~": (0, import_i18n.__)("Tilde") 216 }; 217 return [...modifier(_isApple), character].map( 218 (key) => capitaliseFirstCharacter(replacementKeyMap[key] ?? key) 219 ).join(isApple ? " " : " + "); 220 }; 221 }); 222 var keyboardShortcut = /* @__PURE__ */ Object.fromEntries( 223 Object.keys(modifiers).map( 224 (modifier) => [ 225 modifier, 226 (character, _isApple = isAppleOS) => ({ 227 displayShortcut: displayShortcut[modifier]( 228 character, 229 _isApple 230 ), 231 ariaKeyShortcut: ariaKeyShortcut[modifier]( 232 character, 233 _isApple 234 ), 235 label: shortcutAriaLabel[modifier](character, _isApple) 236 }) 237 ] 238 ) 239 ); 240 function getEventModifiers(event) { 241 return [ALT, CTRL, COMMAND, SHIFT].filter( 242 (key) => event[`$key}Key`] 243 ); 244 } 245 var isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => { 246 return (event, character, _isApple = isAppleOS) => { 247 const mods = getModifiers(_isApple); 248 const eventMods = getEventModifiers(event); 249 const replacementWithShiftKeyMap = { 250 Comma: ",", 251 Backslash: "\\", 252 // Windows returns `\` for both IntlRo and IntlYen. 253 IntlRo: "\\", 254 IntlYen: "\\" 255 }; 256 const modsDiff = mods.filter( 257 (mod) => !eventMods.includes(mod) 258 ); 259 const eventModsDiff = eventMods.filter( 260 (mod) => !mods.includes(mod) 261 ); 262 if (modsDiff.length > 0 || eventModsDiff.length > 0) { 263 return false; 264 } 265 let key = event.key.toLowerCase(); 266 if (!character) { 267 return mods.includes(key); 268 } 269 if (event.altKey && character.length === 1) { 270 key = String.fromCharCode(event.keyCode).toLowerCase(); 271 } 272 if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) { 273 key = replacementWithShiftKeyMap[event.code]; 274 } 275 if (character === "del") { 276 character = "delete"; 277 } 278 return key === character.toLowerCase(); 279 }; 280 }); 281 return __toCommonJS(index_exports); 282 })(); 283 (window.wp ||= {}).keycodes = wp.keycodes; 284 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Fri Oct 9 08:20:33 2026 | Cross-referenced by PHPXref |