PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/scripts/keycodes/index.js +38 -1 23.3.1 → trunk View file →
@@ -1,4 +1,5 @@
1 +(function() {
1 2 "use strict";
2 3 var wp;
3 4 (wp ||= {}).keycodes = (() => {
4 5 var __create = Object.create;
@@ -66,11 +67,13 @@
66 67 displayShortcut: () => displayShortcut,
67 68 displayShortcutList: () => displayShortcutList,
68 69 isAppleOS: () => isAppleOS,
69 70 isKeyboardEvent: () => isKeyboardEvent,
71 + keyboardShortcut: () => keyboardShortcut,
70 72 modifiers: () => modifiers,
71 73 rawShortcut: () => rawShortcut,
72 - shortcutAriaLabel: () => shortcutAriaLabel
74 + shortcutAriaLabel: () => shortcutAriaLabel,
75 + withIgnoreIMEEvents: () => withIgnoreIMEEvents
73 76 });
74 77 var import_i18n = __toESM(require_i18n(), 1);
75 78
76 79 // packages/keycodes/build-module/platform.mjs
@@ -84,8 +87,22 @@
84 87 const { platform } = _window.navigator;
85 88 return platform.indexOf("Mac") !== -1 || ["iPad", "iPhone"].includes(platform);
86 89 }
87 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 +
88 105 // packages/keycodes/build-module/index.mjs
89 106 var BACKSPACE = 8;
90 107 var TAB = 9;
91 108 var ENTER = 13;
@@ -201,8 +218,26 @@
201 218 (key) => capitaliseFirstCharacter(replacementKeyMap[key] ?? key)
202 219 ).join(isApple ? " " : " + ");
203 220 };
204 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 + );
205 240 function getEventModifiers(event) {
206 241 return [ALT, CTRL, COMMAND, SHIFT].filter(
207 242 (key) => event[`${key}Key`]
208 243 );
@@ -243,6 +278,8 @@
243 278 return key === character.toLowerCase();
244 279 };
245 280 });
246 281 return __toCommonJS(index_exports);
282 +})();
283 +(window.wp ||= {}).keycodes = wp.keycodes;
247 284 })();
248 285 //# sourceMappingURL=index.js.map