| [ 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 modifiers: () => modifiers, 72 rawShortcut: () => rawShortcut, 73 shortcutAriaLabel: () => shortcutAriaLabel, 74 withIgnoreIMEEvents: () => withIgnoreIMEEvents 75 }); 76 var import_i18n = __toESM(require_i18n(), 1); 77 78 // packages/keycodes/build-module/platform.mjs 79 function isAppleOS(_window) { 80 if (!_window) { 81 if (typeof window === "undefined") { 82 return false; 83 } 84 _window = window; 85 } 86 const { platform } = _window.navigator; 87 return platform.indexOf("Mac") !== -1 || ["iPad", "iPhone"].includes(platform); 88 } 89 90 // packages/keycodes/build-module/with-ignore-ime-events.mjs 91 function withIgnoreIMEEvents(handler) { 92 return (event) => { 93 const { isComposing } = "nativeEvent" in event ? event.nativeEvent : event; 94 if (isComposing || // Workaround for Mac Safari where the final Enter/Backspace of an IME composition 95 // is `isComposing=false`, even though it's technically still part of the composition. 96 // These can only be detected by keyCode. 97 event.keyCode === 229) { 98 return; 99 } 100 handler(event); 101 }; 102 } 103 104 // packages/keycodes/build-module/index.mjs 105 var BACKSPACE = 8; 106 var TAB = 9; 107 var ENTER = 13; 108 var ESCAPE = 27; 109 var SPACE = 32; 110 var PAGEUP = 33; 111 var PAGEDOWN = 34; 112 var END = 35; 113 var HOME = 36; 114 var LEFT = 37; 115 var UP = 38; 116 var RIGHT = 39; 117 var DOWN = 40; 118 var DELETE = 46; 119 var F10 = 121; 120 var ALT = "alt"; 121 var CTRL = "ctrl"; 122 var COMMAND = "meta"; 123 var SHIFT = "shift"; 124 var ZERO = 48; 125 function capitaliseFirstCharacter(string) { 126 return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1); 127 } 128 function mapValues(object, mapFn) { 129 return Object.fromEntries( 130 Object.entries(object).map(([key, value]) => [ 131 key, 132 mapFn(value) 133 ]) 134 ); 135 } 136 var modifiers = { 137 primary: (_isApple) => _isApple() ? [COMMAND] : [CTRL], 138 primaryShift: (_isApple) => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT], 139 primaryAlt: (_isApple) => _isApple() ? [ALT, COMMAND] : [CTRL, ALT], 140 secondary: (_isApple) => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT], 141 access: (_isApple) => _isApple() ? [CTRL, ALT] : [SHIFT, ALT], 142 ctrl: () => [CTRL], 143 alt: () => [ALT], 144 ctrlShift: () => [CTRL, SHIFT], 145 shift: () => [SHIFT], 146 shiftAlt: () => [SHIFT, ALT], 147 undefined: () => [] 148 }; 149 var rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => { 150 return (character, _isApple = isAppleOS) => { 151 return [...modifier(_isApple), character.toLowerCase()].join( 152 "+" 153 ); 154 }; 155 }); 156 var ariaKeyShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => { 157 return (character, _isApple = isAppleOS) => { 158 return [ 159 ...modifier(_isApple).map((key) => key === CTRL ? "Control" : key).map((key) => capitaliseFirstCharacter(key)), 160 capitaliseFirstCharacter(character) 161 ].join("+"); 162 }; 163 }); 164 var displayShortcutList = /* @__PURE__ */ mapValues( 165 modifiers, 166 (modifier) => { 167 return (character, _isApple = isAppleOS) => { 168 const isApple = _isApple(); 169 const replacementKeyMap = { 170 [ALT]: isApple ? "\u2325" : "Alt", 171 [CTRL]: isApple ? "\u2303" : "Ctrl", 172 // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character. 173 [COMMAND]: "\u2318", 174 [SHIFT]: isApple ? "\u21E7" : "Shift" 175 }; 176 const modifierKeys = modifier(_isApple).reduce( 177 (accumulator, key) => { 178 const replacementKey = replacementKeyMap[key] ?? key; 179 if (isApple) { 180 return [...accumulator, replacementKey]; 181 } 182 return [...accumulator, replacementKey, "+"]; 183 }, 184 [] 185 ); 186 return [ 187 ...modifierKeys, 188 capitaliseFirstCharacter(character) 189 ]; 190 }; 191 } 192 ); 193 var displayShortcut = /* @__PURE__ */ mapValues( 194 displayShortcutList, 195 (shortcutList) => { 196 return (character, _isApple = isAppleOS) => shortcutList(character, _isApple).join(""); 197 } 198 ); 199 var shortcutAriaLabel = /* @__PURE__ */ mapValues(modifiers, (modifier) => { 200 return (character, _isApple = isAppleOS) => { 201 const isApple = _isApple(); 202 const replacementKeyMap = { 203 [SHIFT]: "Shift", 204 [COMMAND]: isApple ? "Command" : "Control", 205 [CTRL]: "Control", 206 [ALT]: isApple ? "Option" : "Alt", 207 /* translators: comma as in the character ',' */ 208 ",": (0, import_i18n.__)("Comma"), 209 /* translators: period as in the character '.' */ 210 ".": (0, import_i18n.__)("Period"), 211 /* translators: backtick as in the character '`' */ 212 "`": (0, import_i18n.__)("Backtick"), 213 /* translators: tilde as in the character '~' */ 214 "~": (0, import_i18n.__)("Tilde") 215 }; 216 return [...modifier(_isApple), character].map( 217 (key) => capitaliseFirstCharacter(replacementKeyMap[key] ?? key) 218 ).join(isApple ? " " : " + "); 219 }; 220 }); 221 function getEventModifiers(event) { 222 return [ALT, CTRL, COMMAND, SHIFT].filter( 223 (key) => event[`$key}Key`] 224 ); 225 } 226 var isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => { 227 return (event, character, _isApple = isAppleOS) => { 228 const mods = getModifiers(_isApple); 229 const eventMods = getEventModifiers(event); 230 const replacementWithShiftKeyMap = { 231 Comma: ",", 232 Backslash: "\\", 233 // Windows returns `\` for both IntlRo and IntlYen. 234 IntlRo: "\\", 235 IntlYen: "\\" 236 }; 237 const modsDiff = mods.filter( 238 (mod) => !eventMods.includes(mod) 239 ); 240 const eventModsDiff = eventMods.filter( 241 (mod) => !mods.includes(mod) 242 ); 243 if (modsDiff.length > 0 || eventModsDiff.length > 0) { 244 return false; 245 } 246 let key = event.key.toLowerCase(); 247 if (!character) { 248 return mods.includes(key); 249 } 250 if (event.altKey && character.length === 1) { 251 key = String.fromCharCode(event.keyCode).toLowerCase(); 252 } 253 if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) { 254 key = replacementWithShiftKeyMap[event.code]; 255 } 256 if (character === "del") { 257 character = "delete"; 258 } 259 return key === character.toLowerCase(); 260 }; 261 }); 262 return __toCommonJS(index_exports); 263 })(); 264 (window.wp ||= {}).keycodes = wp.keycodes; 265 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Tue Sep 15 08:20:32 2026 | Cross-referenced by PHPXref |