80 /******/ // __webpack_public_path__ |
80 /******/ // __webpack_public_path__ |
81 /******/ __webpack_require__.p = ""; |
81 /******/ __webpack_require__.p = ""; |
82 /******/ |
82 /******/ |
83 /******/ |
83 /******/ |
84 /******/ // Load entry module and return exports |
84 /******/ // Load entry module and return exports |
85 /******/ return __webpack_require__(__webpack_require__.s = 466); |
85 /******/ return __webpack_require__(__webpack_require__.s = "z7pY"); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 1: |
90 /***/ "YLtl": |
91 /***/ (function(module, exports) { |
91 /***/ (function(module, exports) { |
92 |
92 |
93 (function() { module.exports = this["wp"]["i18n"]; }()); |
93 (function() { module.exports = window["lodash"]; }()); |
94 |
94 |
95 /***/ }), |
95 /***/ }), |
96 |
96 |
97 /***/ 18: |
97 /***/ "l3Sj": |
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
98 /***/ (function(module, exports) { |
99 |
99 |
100 "use strict"; |
100 (function() { module.exports = window["wp"]["i18n"]; }()); |
101 |
|
102 // EXPORTS |
|
103 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; }); |
|
104 |
|
105 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js |
|
106 var arrayLikeToArray = __webpack_require__(26); |
|
107 |
|
108 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
109 |
|
110 function _arrayWithoutHoles(arr) { |
|
111 if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr); |
|
112 } |
|
113 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
114 var iterableToArray = __webpack_require__(35); |
|
115 |
|
116 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js |
|
117 var unsupportedIterableToArray = __webpack_require__(29); |
|
118 |
|
119 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
120 function _nonIterableSpread() { |
|
121 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
|
122 } |
|
123 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 function _toConsumableArray(arr) { |
|
129 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
130 } |
|
131 |
101 |
132 /***/ }), |
102 /***/ }), |
133 |
103 |
134 /***/ 2: |
104 /***/ "z7pY": |
135 /***/ (function(module, exports) { |
|
136 |
|
137 (function() { module.exports = this["lodash"]; }()); |
|
138 |
|
139 /***/ }), |
|
140 |
|
141 /***/ 26: |
|
142 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
143 |
|
144 "use strict"; |
|
145 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; }); |
|
146 function _arrayLikeToArray(arr, len) { |
|
147 if (len == null || len > arr.length) len = arr.length; |
|
148 |
|
149 for (var i = 0, arr2 = new Array(len); i < len; i++) { |
|
150 arr2[i] = arr[i]; |
|
151 } |
|
152 |
|
153 return arr2; |
|
154 } |
|
155 |
|
156 /***/ }), |
|
157 |
|
158 /***/ 29: |
|
159 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
160 |
|
161 "use strict"; |
|
162 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); |
|
163 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26); |
|
164 |
|
165 function _unsupportedIterableToArray(o, minLen) { |
|
166 if (!o) return; |
|
167 if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
168 var n = Object.prototype.toString.call(o).slice(8, -1); |
|
169 if (n === "Object" && o.constructor) n = o.constructor.name; |
|
170 if (n === "Map" || n === "Set") return Array.from(o); |
|
171 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
172 } |
|
173 |
|
174 /***/ }), |
|
175 |
|
176 /***/ 35: |
|
177 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
178 |
|
179 "use strict"; |
|
180 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
181 function _iterableToArray(iter) { |
|
182 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); |
|
183 } |
|
184 |
|
185 /***/ }), |
|
186 |
|
187 /***/ 466: |
|
188 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
105 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
189 |
106 |
190 "use strict"; |
107 "use strict"; |
191 // ESM COMPAT FLAG |
108 // ESM COMPAT FLAG |
192 __webpack_require__.r(__webpack_exports__); |
109 __webpack_require__.r(__webpack_exports__); |
213 __webpack_require__.d(__webpack_exports__, "displayShortcutList", function() { return /* binding */ displayShortcutList; }); |
130 __webpack_require__.d(__webpack_exports__, "displayShortcutList", function() { return /* binding */ displayShortcutList; }); |
214 __webpack_require__.d(__webpack_exports__, "displayShortcut", function() { return /* binding */ displayShortcut; }); |
131 __webpack_require__.d(__webpack_exports__, "displayShortcut", function() { return /* binding */ displayShortcut; }); |
215 __webpack_require__.d(__webpack_exports__, "shortcutAriaLabel", function() { return /* binding */ shortcutAriaLabel; }); |
132 __webpack_require__.d(__webpack_exports__, "shortcutAriaLabel", function() { return /* binding */ shortcutAriaLabel; }); |
216 __webpack_require__.d(__webpack_exports__, "isKeyboardEvent", function() { return /* binding */ isKeyboardEvent; }); |
133 __webpack_require__.d(__webpack_exports__, "isKeyboardEvent", function() { return /* binding */ isKeyboardEvent; }); |
217 |
134 |
218 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
135 // EXTERNAL MODULE: external "lodash" |
219 var defineProperty = __webpack_require__(5); |
136 var external_lodash_ = __webpack_require__("YLtl"); |
220 |
137 |
221 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
138 // EXTERNAL MODULE: external ["wp","i18n"] |
222 var toConsumableArray = __webpack_require__(18); |
139 var external_wp_i18n_ = __webpack_require__("l3Sj"); |
223 |
|
224 // EXTERNAL MODULE: external {"this":"lodash"} |
|
225 var external_this_lodash_ = __webpack_require__(2); |
|
226 |
|
227 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
228 var external_this_wp_i18n_ = __webpack_require__(1); |
|
229 |
140 |
230 // CONCATENATED MODULE: ./node_modules/@wordpress/keycodes/build-module/platform.js |
141 // CONCATENATED MODULE: ./node_modules/@wordpress/keycodes/build-module/platform.js |
231 /** |
142 /** |
232 * External dependencies |
143 * External dependencies |
233 */ |
144 */ |
234 |
145 |
235 /** |
146 /** |
236 * Return true if platform is MacOS. |
147 * Return true if platform is MacOS. |
237 * |
148 * |
238 * @param {Object} _window window object by default; used for DI testing. |
149 * @param {Window?} _window window object by default; used for DI testing. |
239 * |
150 * |
240 * @return {boolean} True if MacOS; false otherwise. |
151 * @return {boolean} True if MacOS; false otherwise. |
241 */ |
152 */ |
242 |
153 |
243 function isAppleOS() { |
154 function isAppleOS(_window = null) { |
244 var _window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window; |
155 if (!_window) { |
245 |
156 if (typeof window === 'undefined') { |
246 var platform = _window.navigator.platform; |
157 return false; |
247 return platform.indexOf('Mac') !== -1 || Object(external_this_lodash_["includes"])(['iPad', 'iPhone'], platform); |
158 } |
|
159 |
|
160 _window = window; |
|
161 } |
|
162 |
|
163 const { |
|
164 platform |
|
165 } = _window.navigator; |
|
166 return platform.indexOf('Mac') !== -1 || Object(external_lodash_["includes"])(['iPad', 'iPhone'], platform); |
248 } |
167 } |
249 |
168 |
250 // CONCATENATED MODULE: ./node_modules/@wordpress/keycodes/build-module/index.js |
169 // CONCATENATED MODULE: ./node_modules/@wordpress/keycodes/build-module/index.js |
251 |
|
252 |
|
253 |
|
254 /** |
170 /** |
255 * Note: The order of the modifier keys in many of the [foo]Shortcut() |
171 * Note: The order of the modifier keys in many of the [foo]Shortcut() |
256 * functions in this file are intentional and should not be changed. They're |
172 * functions in this file are intentional and should not be changed. They're |
257 * designed to fit with the standard menu keyboard shortcuts shown in the |
173 * designed to fit with the standard menu keyboard shortcuts shown in the |
258 * user's platform. |
174 * user's platform. |
274 /** |
190 /** |
275 * Internal dependencies |
191 * Internal dependencies |
276 */ |
192 */ |
277 |
193 |
278 |
194 |
279 /** |
195 /** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */ |
280 * @typedef {'primary'|'primaryShift'|'primaryAlt'|'secondary'|'access'|'ctrl'|'alt'|'ctrlShift'|'shift'|'shiftAlt'} WPKeycodeModifier |
196 |
281 */ |
197 /** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt'} WPKeycodeModifier */ |
282 |
198 |
283 /** |
199 /** |
284 * An object of handler functions for each of the possible modifier |
200 * An object of handler functions for each of the possible modifier |
285 * combinations. A handler will return a value for a given key. |
201 * combinations. A handler will return a value for a given key. |
286 * |
202 * |
287 * @typedef {Record<WPKeycodeModifier, (key:string)=>any>} WPKeycodeHandlerByModifier |
203 * @template T |
288 */ |
204 * |
|
205 * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler |
|
206 */ |
|
207 |
|
208 /** |
|
209 * @template T |
|
210 * |
|
211 * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler |
|
212 */ |
|
213 |
|
214 /** @typedef {(event: KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */ |
289 |
215 |
290 /** |
216 /** |
291 * Keycode for BACKSPACE key. |
217 * Keycode for BACKSPACE key. |
292 */ |
218 */ |
293 |
219 |
294 var BACKSPACE = 8; |
220 const BACKSPACE = 8; |
295 /** |
221 /** |
296 * Keycode for TAB key. |
222 * Keycode for TAB key. |
297 */ |
223 */ |
298 |
224 |
299 var TAB = 9; |
225 const TAB = 9; |
300 /** |
226 /** |
301 * Keycode for ENTER key. |
227 * Keycode for ENTER key. |
302 */ |
228 */ |
303 |
229 |
304 var ENTER = 13; |
230 const ENTER = 13; |
305 /** |
231 /** |
306 * Keycode for ESCAPE key. |
232 * Keycode for ESCAPE key. |
307 */ |
233 */ |
308 |
234 |
309 var ESCAPE = 27; |
235 const ESCAPE = 27; |
310 /** |
236 /** |
311 * Keycode for SPACE key. |
237 * Keycode for SPACE key. |
312 */ |
238 */ |
313 |
239 |
314 var SPACE = 32; |
240 const SPACE = 32; |
315 /** |
241 /** |
316 * Keycode for LEFT key. |
242 * Keycode for LEFT key. |
317 */ |
243 */ |
318 |
244 |
319 var LEFT = 37; |
245 const LEFT = 37; |
320 /** |
246 /** |
321 * Keycode for UP key. |
247 * Keycode for UP key. |
322 */ |
248 */ |
323 |
249 |
324 var UP = 38; |
250 const UP = 38; |
325 /** |
251 /** |
326 * Keycode for RIGHT key. |
252 * Keycode for RIGHT key. |
327 */ |
253 */ |
328 |
254 |
329 var RIGHT = 39; |
255 const RIGHT = 39; |
330 /** |
256 /** |
331 * Keycode for DOWN key. |
257 * Keycode for DOWN key. |
332 */ |
258 */ |
333 |
259 |
334 var DOWN = 40; |
260 const DOWN = 40; |
335 /** |
261 /** |
336 * Keycode for DELETE key. |
262 * Keycode for DELETE key. |
337 */ |
263 */ |
338 |
264 |
339 var DELETE = 46; |
265 const DELETE = 46; |
340 /** |
266 /** |
341 * Keycode for F10 key. |
267 * Keycode for F10 key. |
342 */ |
268 */ |
343 |
269 |
344 var F10 = 121; |
270 const F10 = 121; |
345 /** |
271 /** |
346 * Keycode for ALT key. |
272 * Keycode for ALT key. |
347 */ |
273 */ |
348 |
274 |
349 var ALT = 'alt'; |
275 const ALT = 'alt'; |
350 /** |
276 /** |
351 * Keycode for CTRL key. |
277 * Keycode for CTRL key. |
352 */ |
278 */ |
353 |
279 |
354 var CTRL = 'ctrl'; |
280 const CTRL = 'ctrl'; |
355 /** |
281 /** |
356 * Keycode for COMMAND/META key. |
282 * Keycode for COMMAND/META key. |
357 */ |
283 */ |
358 |
284 |
359 var COMMAND = 'meta'; |
285 const COMMAND = 'meta'; |
360 /** |
286 /** |
361 * Keycode for SHIFT key. |
287 * Keycode for SHIFT key. |
362 */ |
288 */ |
363 |
289 |
364 var SHIFT = 'shift'; |
290 const SHIFT = 'shift'; |
365 /** |
291 /** |
366 * Keycode for ZERO key. |
292 * Keycode for ZERO key. |
367 */ |
293 */ |
368 |
294 |
369 var ZERO = 48; |
295 const ZERO = 48; |
370 /** |
296 /** |
371 * Object that contains functions that return the available modifier |
297 * Object that contains functions that return the available modifier |
372 * depending on platform. |
298 * depending on platform. |
373 * |
299 * |
374 * - `primary`: takes a isApple function as a parameter. |
300 * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>} |
375 * - `primaryShift`: takes a isApple function as a parameter. |
301 */ |
376 * - `primaryAlt`: takes a isApple function as a parameter. |
302 |
377 * - `secondary`: takes a isApple function as a parameter. |
303 const modifiers = { |
378 * - `access`: takes a isApple function as a parameter. |
304 primary: _isApple => _isApple() ? [COMMAND] : [CTRL], |
379 * - `ctrl` |
305 primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT], |
380 * - `alt` |
306 primaryAlt: _isApple => _isApple() ? [ALT, COMMAND] : [CTRL, ALT], |
381 * - `ctrlShift` |
307 secondary: _isApple => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT], |
382 * - `shift` |
308 access: _isApple => _isApple() ? [CTRL, ALT] : [SHIFT, ALT], |
383 * - `shiftAlt` |
309 ctrl: () => [CTRL], |
384 */ |
310 alt: () => [ALT], |
385 |
311 ctrlShift: () => [CTRL, SHIFT], |
386 var modifiers = { |
312 shift: () => [SHIFT], |
387 primary: function primary(_isApple) { |
313 shiftAlt: () => [SHIFT, ALT] |
388 return _isApple() ? [COMMAND] : [CTRL]; |
|
389 }, |
|
390 primaryShift: function primaryShift(_isApple) { |
|
391 return _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT]; |
|
392 }, |
|
393 primaryAlt: function primaryAlt(_isApple) { |
|
394 return _isApple() ? [ALT, COMMAND] : [CTRL, ALT]; |
|
395 }, |
|
396 secondary: function secondary(_isApple) { |
|
397 return _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT]; |
|
398 }, |
|
399 access: function access(_isApple) { |
|
400 return _isApple() ? [CTRL, ALT] : [SHIFT, ALT]; |
|
401 }, |
|
402 ctrl: function ctrl() { |
|
403 return [CTRL]; |
|
404 }, |
|
405 alt: function alt() { |
|
406 return [ALT]; |
|
407 }, |
|
408 ctrlShift: function ctrlShift() { |
|
409 return [CTRL, SHIFT]; |
|
410 }, |
|
411 shift: function shift() { |
|
412 return [SHIFT]; |
|
413 }, |
|
414 shiftAlt: function shiftAlt() { |
|
415 return [SHIFT, ALT]; |
|
416 } |
|
417 }; |
314 }; |
418 /** |
315 /** |
419 * An object that contains functions to get raw shortcuts. |
316 * An object that contains functions to get raw shortcuts. |
420 * E.g. rawShortcut.primary( 'm' ) will return 'meta+m' on Mac. |
317 * |
421 * These are intended for user with the KeyboardShortcuts component or TinyMCE. |
318 * These are intended for user with the KeyboardShortcuts. |
422 * |
319 * |
423 * @type {WPKeycodeHandlerByModifier} Keyed map of functions to raw shortcuts. |
320 * @example |
424 */ |
321 * ```js |
425 |
322 * // Assuming macOS: |
426 var rawShortcut = Object(external_this_lodash_["mapValues"])(modifiers, function (modifier) { |
323 * rawShortcut.primary( 'm' ) |
427 return function (character) { |
324 * // "meta+m"" |
428 var _isApple = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isAppleOS; |
325 * ``` |
429 |
326 * |
430 return [].concat(Object(toConsumableArray["a" /* default */])(modifier(_isApple)), [character.toLowerCase()]).join('+'); |
327 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw |
431 }; |
328 * shortcuts. |
|
329 */ |
|
330 |
|
331 const rawShortcut = Object(external_lodash_["mapValues"])(modifiers, modifier => { |
|
332 return ( |
|
333 /** @type {WPKeyHandler<string>} */ |
|
334 (character, _isApple = isAppleOS) => { |
|
335 return [...modifier(_isApple), character.toLowerCase()].join('+'); |
|
336 } |
|
337 ); |
432 }); |
338 }); |
433 /** |
339 /** |
434 * Return an array of the parts of a keyboard shortcut chord for display |
340 * Return an array of the parts of a keyboard shortcut chord for display. |
435 * E.g displayShortcutList.primary( 'm' ) will return [ '⌘', 'M' ] on Mac. |
341 * |
436 * |
342 * @example |
437 * @type {WPKeycodeHandlerByModifier} Keyed map of functions to shortcut |
343 * ```js |
438 * sequences. |
344 * // Assuming macOS: |
439 */ |
345 * displayShortcutList.primary( 'm' ); |
440 |
346 * // [ "⌘", "M" ] |
441 var displayShortcutList = Object(external_this_lodash_["mapValues"])(modifiers, function (modifier) { |
347 * ``` |
442 return function (character) { |
348 * |
443 var _replacementKeyMap; |
349 * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to |
444 |
350 * shortcut sequences. |
445 var _isApple = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isAppleOS; |
351 */ |
446 |
352 |
447 var isApple = _isApple(); |
353 const displayShortcutList = Object(external_lodash_["mapValues"])(modifiers, modifier => { |
448 |
354 return ( |
449 var replacementKeyMap = (_replacementKeyMap = {}, Object(defineProperty["a" /* default */])(_replacementKeyMap, ALT, isApple ? '⌥' : 'Alt'), Object(defineProperty["a" /* default */])(_replacementKeyMap, CTRL, isApple ? '^' : 'Ctrl'), Object(defineProperty["a" /* default */])(_replacementKeyMap, COMMAND, '⌘'), Object(defineProperty["a" /* default */])(_replacementKeyMap, SHIFT, isApple ? '⇧' : 'Shift'), _replacementKeyMap); |
355 /** @type {WPKeyHandler<string[]>} */ |
450 var modifierKeys = modifier(_isApple).reduce(function (accumulator, key) { |
356 (character, _isApple = isAppleOS) => { |
451 var replacementKey = Object(external_this_lodash_["get"])(replacementKeyMap, key, key); // If on the Mac, adhere to platform convention and don't show plus between keys. |
357 const isApple = _isApple(); |
452 |
358 |
453 if (isApple) { |
359 const replacementKeyMap = { |
454 return [].concat(Object(toConsumableArray["a" /* default */])(accumulator), [replacementKey]); |
360 [ALT]: isApple ? '⌥' : 'Alt', |
455 } |
361 [CTRL]: isApple ? '⌃' : 'Ctrl', |
456 |
362 // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character. |
457 return [].concat(Object(toConsumableArray["a" /* default */])(accumulator), [replacementKey, '+']); |
363 [COMMAND]: '⌘', |
458 }, []); |
364 [SHIFT]: isApple ? '⇧' : 'Shift' |
459 var capitalizedCharacter = Object(external_this_lodash_["capitalize"])(character); |
365 }; |
460 return [].concat(Object(toConsumableArray["a" /* default */])(modifierKeys), [capitalizedCharacter]); |
366 const modifierKeys = modifier(_isApple).reduce((accumulator, key) => { |
461 }; |
367 const replacementKey = Object(external_lodash_["get"])(replacementKeyMap, key, key); // If on the Mac, adhere to platform convention and don't show plus between keys. |
|
368 |
|
369 if (isApple) { |
|
370 return [...accumulator, replacementKey]; |
|
371 } |
|
372 |
|
373 return [...accumulator, replacementKey, '+']; |
|
374 }, |
|
375 /** @type {string[]} */ |
|
376 []); |
|
377 const capitalizedCharacter = Object(external_lodash_["capitalize"])(character); |
|
378 return [...modifierKeys, capitalizedCharacter]; |
|
379 } |
|
380 ); |
462 }); |
381 }); |
463 /** |
382 /** |
464 * An object that contains functions to display shortcuts. |
383 * An object that contains functions to display shortcuts. |
465 * E.g. displayShortcut.primary( 'm' ) will return '⌘M' on Mac. |
384 * |
466 * |
385 * @example |
467 * @type {WPKeycodeHandlerByModifier} Keyed map of functions to display |
386 * ```js |
468 * shortcuts. |
387 * // Assuming macOS: |
469 */ |
388 * displayShortcut.primary( 'm' ); |
470 |
389 * // "⌘M" |
471 var displayShortcut = Object(external_this_lodash_["mapValues"])(displayShortcutList, function (shortcutList) { |
390 * ``` |
472 return function (character) { |
391 * |
473 var _isApple = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isAppleOS; |
392 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to |
474 |
393 * display shortcuts. |
475 return shortcutList(character, _isApple).join(''); |
394 */ |
476 }; |
395 |
|
396 const displayShortcut = Object(external_lodash_["mapValues"])(displayShortcutList, shortcutList => { |
|
397 return ( |
|
398 /** @type {WPKeyHandler<string>} */ |
|
399 (character, _isApple = isAppleOS) => shortcutList(character, _isApple).join('') |
|
400 ); |
477 }); |
401 }); |
478 /** |
402 /** |
479 * An object that contains functions to return an aria label for a keyboard shortcut. |
403 * An object that contains functions to return an aria label for a keyboard |
480 * E.g. shortcutAriaLabel.primary( '.' ) will return 'Command + Period' on Mac. |
404 * shortcut. |
481 * |
405 * |
482 * @type {WPKeycodeHandlerByModifier} Keyed map of functions to shortcut ARIA |
406 * @example |
483 * labels. |
407 * ```js |
484 */ |
408 * // Assuming macOS: |
485 |
409 * shortcutAriaLabel.primary( '.' ); |
486 var shortcutAriaLabel = Object(external_this_lodash_["mapValues"])(modifiers, function (modifier) { |
410 * // "Command + Period" |
487 return function (character) { |
411 * ``` |
488 var _replacementKeyMap2; |
412 * |
489 |
413 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to |
490 var _isApple = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isAppleOS; |
414 * shortcut ARIA labels. |
491 |
415 */ |
492 var isApple = _isApple(); |
416 |
493 |
417 const shortcutAriaLabel = Object(external_lodash_["mapValues"])(modifiers, modifier => { |
494 var replacementKeyMap = (_replacementKeyMap2 = {}, Object(defineProperty["a" /* default */])(_replacementKeyMap2, SHIFT, 'Shift'), Object(defineProperty["a" /* default */])(_replacementKeyMap2, COMMAND, isApple ? 'Command' : 'Control'), Object(defineProperty["a" /* default */])(_replacementKeyMap2, CTRL, 'Control'), Object(defineProperty["a" /* default */])(_replacementKeyMap2, ALT, isApple ? 'Option' : 'Alt'), Object(defineProperty["a" /* default */])(_replacementKeyMap2, ',', Object(external_this_wp_i18n_["__"])('Comma')), Object(defineProperty["a" /* default */])(_replacementKeyMap2, '.', Object(external_this_wp_i18n_["__"])('Period')), Object(defineProperty["a" /* default */])(_replacementKeyMap2, '`', Object(external_this_wp_i18n_["__"])('Backtick')), _replacementKeyMap2); |
418 return ( |
495 return [].concat(Object(toConsumableArray["a" /* default */])(modifier(_isApple)), [character]).map(function (key) { |
419 /** @type {WPKeyHandler<string>} */ |
496 return Object(external_this_lodash_["capitalize"])(Object(external_this_lodash_["get"])(replacementKeyMap, key, key)); |
420 (character, _isApple = isAppleOS) => { |
497 }).join(isApple ? ' ' : ' + '); |
421 const isApple = _isApple(); |
498 }; |
422 |
|
423 const replacementKeyMap = { |
|
424 [SHIFT]: 'Shift', |
|
425 [COMMAND]: isApple ? 'Command' : 'Control', |
|
426 [CTRL]: 'Control', |
|
427 [ALT]: isApple ? 'Option' : 'Alt', |
|
428 |
|
429 /* translators: comma as in the character ',' */ |
|
430 ',': Object(external_wp_i18n_["__"])('Comma'), |
|
431 |
|
432 /* translators: period as in the character '.' */ |
|
433 '.': Object(external_wp_i18n_["__"])('Period'), |
|
434 |
|
435 /* translators: backtick as in the character '`' */ |
|
436 '`': Object(external_wp_i18n_["__"])('Backtick') |
|
437 }; |
|
438 return [...modifier(_isApple), character].map(key => Object(external_lodash_["capitalize"])(Object(external_lodash_["get"])(replacementKeyMap, key, key))).join(isApple ? ' ' : ' + '); |
|
439 } |
|
440 ); |
499 }); |
441 }); |
500 /** |
442 /** |
501 * From a given KeyboardEvent, returns an array of active modifier constants for |
443 * From a given KeyboardEvent, returns an array of active modifier constants for |
502 * the event. |
444 * the event. |
503 * |
445 * |
504 * @param {KeyboardEvent} event Keyboard event. |
446 * @param {KeyboardEvent} event Keyboard event. |
505 * |
447 * |
506 * @return {Array<ALT|CTRL|COMMAND|SHIFT>} Active modifier constants. |
448 * @return {Array<WPModifierPart>} Active modifier constants. |
507 */ |
449 */ |
508 |
450 |
509 function getEventModifiers(event) { |
451 function getEventModifiers(event) { |
510 return [ALT, CTRL, COMMAND, SHIFT].filter(function (key) { |
452 return ( |
511 return event["".concat(key, "Key")]; |
453 /** @type {WPModifierPart[]} */ |
512 }); |
454 [ALT, CTRL, COMMAND, SHIFT].filter(key => event[ |
|
455 /** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ |
|
456 `${key}Key`]) |
|
457 ); |
513 } |
458 } |
514 /** |
459 /** |
515 * An object that contains functions to check if a keyboard event matches a |
460 * An object that contains functions to check if a keyboard event matches a |
516 * predefined shortcut combination. |
461 * predefined shortcut combination. |
517 * E.g. isKeyboardEvent.primary( event, 'm' ) will return true if the event |
462 * |
518 * signals pressing ⌘M. |
463 * @example |
519 * |
464 * ```js |
520 * @type {WPKeycodeHandlerByModifier} Keyed map of functions to match events. |
465 * // Assuming an event for ⌘M key press: |
521 */ |
466 * isKeyboardEvent.primary( event, 'm' ); |
522 |
467 * // true |
523 |
468 * ``` |
524 var isKeyboardEvent = Object(external_this_lodash_["mapValues"])(modifiers, function (getModifiers) { |
469 * |
525 return function (event, character) { |
470 * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions |
526 var _isApple = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isAppleOS; |
471 * to match events. |
527 |
472 */ |
528 var mods = getModifiers(_isApple); |
473 |
529 var eventMods = getEventModifiers(event); |
474 |
530 |
475 const isKeyboardEvent = Object(external_lodash_["mapValues"])(modifiers, getModifiers => { |
531 if (Object(external_this_lodash_["xor"])(mods, eventMods).length) { |
476 return ( |
532 return false; |
477 /** @type {WPEventKeyHandler} */ |
|
478 (event, character, _isApple = isAppleOS) => { |
|
479 const mods = getModifiers(_isApple); |
|
480 const eventMods = getEventModifiers(event); |
|
481 |
|
482 if (Object(external_lodash_["xor"])(mods, eventMods).length) { |
|
483 return false; |
|
484 } |
|
485 |
|
486 if (!character) { |
|
487 return Object(external_lodash_["includes"])(mods, event.key.toLowerCase()); |
|
488 } |
|
489 |
|
490 return event.key === character; |
533 } |
491 } |
534 |
492 ); |
535 if (!character) { |
|
536 return Object(external_this_lodash_["includes"])(mods, event.key.toLowerCase()); |
|
537 } |
|
538 |
|
539 return event.key === character; |
|
540 }; |
|
541 }); |
493 }); |
542 |
494 |
543 |
495 |
544 /***/ }), |
|
545 |
|
546 /***/ 5: |
|
547 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
548 |
|
549 "use strict"; |
|
550 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
551 function _defineProperty(obj, key, value) { |
|
552 if (key in obj) { |
|
553 Object.defineProperty(obj, key, { |
|
554 value: value, |
|
555 enumerable: true, |
|
556 configurable: true, |
|
557 writable: true |
|
558 }); |
|
559 } else { |
|
560 obj[key] = value; |
|
561 } |
|
562 |
|
563 return obj; |
|
564 } |
|
565 |
|
566 /***/ }) |
496 /***/ }) |
567 |
497 |
568 /******/ }); |
498 /******/ }); |