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