mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 23:21:44 +03:00
55 lines
23 KiB
Diff
55 lines
23 KiB
Diff
|
diff --git a/dist/tinykeys.module.js b/dist/tinykeys.module.js
|
||
|
deleted file mode 100644
|
||
|
index cc374b8fc33dbd90e5daf525e929fd77c89c9c5d..0000000000000000000000000000000000000000
|
||
|
--- a/dist/tinykeys.module.js
|
||
|
+++ /dev/null
|
||
|
@@ -1,2 +0,0 @@
|
||
|
-var t=["Shift","Meta","Alt","Control"],e="object"==typeof navigator?navigator.platform:"",n=/Mac|iPod|iPhone|iPad/.test(e),r=n?"Meta":"Control",o="Win32"===e?["Control","Alt"]:n?["Alt"]:[];function i(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||o.includes(e)&&t.getModifierState("AltGraph"))}function a(t){return t.trim().split(" ").map(function(t){var e=t.split(/\b\+/),n=e.pop();return[e=e.map(function(t){return"$mod"===t?r:t}),n]})}function u(e,n){var r;void 0===n&&(n={});var o=null!=(r=n.timeout)?r:1e3,u=Object.keys(e).map(function(t){return[a(t),e[t]]}),c=new Map,f=null;return function(e){e instanceof KeyboardEvent&&(u.forEach(function(n){var r=n[0],o=n[1],a=c.get(r)||r;!function(e,n){return!(n[1].toUpperCase()!==e.key.toUpperCase()&&n[1]!==e.code||n[0].find(function(t){return!i(e,t)})||t.find(function(t){return!n[0].includes(t)&&n[1]!==t&&i(e,t)}))}(e,a[0])?i(e,e.key)||c.delete(r):a.length>1?c.set(r,a.slice(1)):(c.delete(r),o(e))}),f&&clearTimeout(f),f=setTimeout(c.clear.bind(c),o))}}function c(t,e,n){var r;void 0===n&&(n={});var o=null!=(r=n.event)?r:"keydown",i=u(e,n);return t.addEventListener(o,i),function(){t.removeEventListener(o,i)}}export{u as createKeybindingsHandler,a as parseKeybinding,c as tinykeys};
|
||
|
-//# sourceMappingURL=tinykeys.module.js.map
|
||
|
diff --git a/dist/tinykeys.module.js.map b/dist/tinykeys.module.js.map
|
||
|
deleted file mode 100644
|
||
|
index 0959712c165780d0326d8a524518d9577b0d7f2e..0000000000000000000000000000000000000000
|
||
|
--- a/dist/tinykeys.module.js.map
|
||
|
+++ /dev/null
|
||
|
@@ -1 +0,0 @@
|
||
|
-{"version":3,"file":"tinykeys.module.js","sources":["../src/tinykeys.ts"],"sourcesContent":["type KeyBindingPress = [string[], string]\n\n/**\n * A map of keybinding strings to event handlers.\n */\nexport interface KeyBindingMap {\n\t[keybinding: string]: (event: KeyboardEvent) => void\n}\n\nexport interface KeyBindingHandlerOptions {\n\t/**\n\t * Keybinding sequences will wait this long between key presses before\n\t * cancelling (default: 1000).\n\t *\n\t * **Note:** Setting this value too low (i.e. `300`) will be too fast for many\n\t * of your users.\n\t */\n\ttimeout?: number\n}\n\n/**\n * Options to configure the behavior of keybindings.\n */\nexport interface KeyBindingOptions extends KeyBindingHandlerOptions {\n\t/**\n\t * Key presses will listen to this event (default: \"keydown\").\n\t */\n\tevent?: \"keydown\" | \"keyup\"\n}\n\n/**\n * These are the modifier keys that change the meaning of keybindings.\n *\n * Note: Ignoring \"AltGraph\" because it is covered by the others.\n */\nlet KEYBINDING_MODIFIER_KEYS = [\"Shift\", \"Meta\", \"Alt\", \"Control\"]\n\n/**\n * Keybinding sequences should timeout if individual key presses are more than\n * 1s apart by default.\n */\nlet DEFAULT_TIMEOUT = 1000\n\n/**\n * Keybinding sequences should bind to this event by default.\n */\nlet DEFAULT_EVENT = \"keydown\"\n\n/**\n * Platform detection code.\n * @see https://github.com/jamiebuilds/tinykeys/issues/184\n */\nlet PLATFORM = typeof navigator === \"object\" ? navigator.platform : \"\"\nlet APPLE_DEVICE = /Mac|iPod|iPhone|iPad/.test(PLATFORM)\n\n/**\n * An alias for creating platform-specific keybinding aliases.\n */\nlet MOD = APPLE_DEVICE ? \"Meta\" : \"Control\"\n\n/**\n * Meaning of `AltGraph`, from MDN:\n * - Windows: Both Alt and Ctrl keys are pressed, or AltGr key is pressed\n * - Mac: ⌥ Option key pressed\n * - Linux: Level 3 Shift key (or Level 5 Shift key) pressed\n * - Android: Not supported\n * @see https://github.com/jamiebuilds/tinykeys/issues/185\n */\nlet ALT_GRAPH_ALIASES =\n\tPLATFORM === \"Win32\" ? [\"Control\", \"Alt\"] : APPLE_DEVICE ? [\"Alt\"] : []\n\n/**\n * There's a bug in Chrome that causes event.getModifierState not to exist on\n * KeyboardEvent's for F1/F2/etc keys.\n */\nfunction getModifierState(event: KeyboardEvent, mod: string) {\n\treturn typeof event.getModifierState === \"function\"\n\t\t? event.getModifierState(mod) ||\n\t\t\t\t(ALT_GRAPH_ALIASES.includes(mod) && event.getModifierState(\"AltGraph\"))\n\t\t: false\n}\n\n/**\n * Parses a \"Key Binding String\" into its parts\n *\n * grammar = `<sequence>`\n * <sequence> = `<press> <press> <press> ...`\n * <press> = `<key>` or `<mods>+<key>`\n * <mods> = `<mod>+<mod>+...`\n */\nexport function parseKeybinding(str: string): KeyBindingPress[] {\n\treturn str\n\t\t.trim()\n\t\t.split(\" \")\n\t\t.map(press => {\n\t\t\tlet mods = press.split(/\\b\\+/)\n\t\t\tlet key = mods.pop() as string\n\t\t\tmods = mods.map(mod => (mod === \"$mod\" ? MOD : mod))\n\t\t\treturn [mods, key]\n\t\t})\n}\n\n/**\n * This tells us if a series of events matches a key binding sequence either\n * partially or exactly.\n */\nfunction match(event: KeyboardEvent, press: KeyBindingPress): boolean {\n\t// prettier-ignore\n\treturn !(\n\t\t// Allow either the `event.key` or the `event.code`\n\t\t// MDN event.key: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key\n\t\t// MDN event.code: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code\n\t\t(\n\t\t\tpress[1].toUpperCase() !== event.key.toUpperCase() &&\n\t\t\tpress[1] !== event.code\n\t\t) ||\n\n\t\t// Ensure all the modifiers in the keybinding are pressed.\n\t\tpress[0].find(mod => {\n\t\t\treturn !getModifierState(event, mod)\n\t\t}) ||\n\n\t\t// KEYBINDING_MODIFIER_KEYS (Shift/Control/etc) change the meaning of a\n\t\t// keybinding. So if they are pressed but aren't part of the current\n\t\t// keybinding press, then we don't have a match.\n\t\tKEYBINDING_MODIFIER_KEYS.find(mod => {\n\t\t\treturn !press[0].includes(mod) && press[1] !== mod && getModifierState(event, mod
|
||
|
\ No newline at end of file
|
||
|
diff --git a/dist/tinykeys.module.mjs b/dist/tinykeys.module.mjs
|
||
|
new file mode 100644
|
||
|
index 0000000000000000000000000000000000000000..cc374b8fc33dbd90e5daf525e929fd77c89c9c5d
|
||
|
--- /dev/null
|
||
|
+++ b/dist/tinykeys.module.mjs
|
||
|
@@ -0,0 +1,2 @@
|
||
|
+var t=["Shift","Meta","Alt","Control"],e="object"==typeof navigator?navigator.platform:"",n=/Mac|iPod|iPhone|iPad/.test(e),r=n?"Meta":"Control",o="Win32"===e?["Control","Alt"]:n?["Alt"]:[];function i(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||o.includes(e)&&t.getModifierState("AltGraph"))}function a(t){return t.trim().split(" ").map(function(t){var e=t.split(/\b\+/),n=e.pop();return[e=e.map(function(t){return"$mod"===t?r:t}),n]})}function u(e,n){var r;void 0===n&&(n={});var o=null!=(r=n.timeout)?r:1e3,u=Object.keys(e).map(function(t){return[a(t),e[t]]}),c=new Map,f=null;return function(e){e instanceof KeyboardEvent&&(u.forEach(function(n){var r=n[0],o=n[1],a=c.get(r)||r;!function(e,n){return!(n[1].toUpperCase()!==e.key.toUpperCase()&&n[1]!==e.code||n[0].find(function(t){return!i(e,t)})||t.find(function(t){return!n[0].includes(t)&&n[1]!==t&&i(e,t)}))}(e,a[0])?i(e,e.key)||c.delete(r):a.length>1?c.set(r,a.slice(1)):(c.delete(r),o(e))}),f&&clearTimeout(f),f=setTimeout(c.clear.bind(c),o))}}function c(t,e,n){var r;void 0===n&&(n={});var o=null!=(r=n.event)?r:"keydown",i=u(e,n);return t.addEventListener(o,i),function(){t.removeEventListener(o,i)}}export{u as createKeybindingsHandler,a as parseKeybinding,c as tinykeys};
|
||
|
+//# sourceMappingURL=tinykeys.module.js.map
|
||
|
diff --git a/dist/tinykeys.module.mjs.map b/dist/tinykeys.module.mjs.map
|
||
|
new file mode 100644
|
||
|
index 0000000000000000000000000000000000000000..0959712c165780d0326d8a524518d9577b0d7f2e
|
||
|
--- /dev/null
|
||
|
+++ b/dist/tinykeys.module.mjs.map
|
||
|
@@ -0,0 +1 @@
|
||
|
+{"version":3,"file":"tinykeys.module.js","sources":["../src/tinykeys.ts"],"sourcesContent":["type KeyBindingPress = [string[], string]\n\n/**\n * A map of keybinding strings to event handlers.\n */\nexport interface KeyBindingMap {\n\t[keybinding: string]: (event: KeyboardEvent) => void\n}\n\nexport interface KeyBindingHandlerOptions {\n\t/**\n\t * Keybinding sequences will wait this long between key presses before\n\t * cancelling (default: 1000).\n\t *\n\t * **Note:** Setting this value too low (i.e. `300`) will be too fast for many\n\t * of your users.\n\t */\n\ttimeout?: number\n}\n\n/**\n * Options to configure the behavior of keybindings.\n */\nexport interface KeyBindingOptions extends KeyBindingHandlerOptions {\n\t/**\n\t * Key presses will listen to this event (default: \"keydown\").\n\t */\n\tevent?: \"keydown\" | \"keyup\"\n}\n\n/**\n * These are the modifier keys that change the meaning of keybindings.\n *\n * Note: Ignoring \"AltGraph\" because it is covered by the others.\n */\nlet KEYBINDING_MODIFIER_KEYS = [\"Shift\", \"Meta\", \"Alt\", \"Control\"]\n\n/**\n * Keybinding sequences should timeout if individual key presses are more than\n * 1s apart by default.\n */\nlet DEFAULT_TIMEOUT = 1000\n\n/**\n * Keybinding sequences should bind to this event by default.\n */\nlet DEFAULT_EVENT = \"keydown\"\n\n/**\n * Platform detection code.\n * @see https://github.com/jamiebuilds/tinykeys/issues/184\n */\nlet PLATFORM = typeof navigator === \"object\" ? navigator.platform : \"\"\nlet APPLE_DEVICE = /Mac|iPod|iPhone|iPad/.test(PLATFORM)\n\n/**\n * An alias for creating platform-specific keybinding aliases.\n */\nlet MOD = APPLE_DEVICE ? \"Meta\" : \"Control\"\n\n/**\n * Meaning of `AltGraph`, from MDN:\n * - Windows: Both Alt and Ctrl keys are pressed, or AltGr key is pressed\n * - Mac: ⌥ Option key pressed\n * - Linux: Level 3 Shift key (or Level 5 Shift key) pressed\n * - Android: Not supported\n * @see https://github.com/jamiebuilds/tinykeys/issues/185\n */\nlet ALT_GRAPH_ALIASES =\n\tPLATFORM === \"Win32\" ? [\"Control\", \"Alt\"] : APPLE_DEVICE ? [\"Alt\"] : []\n\n/**\n * There's a bug in Chrome that causes event.getModifierState not to exist on\n * KeyboardEvent's for F1/F2/etc keys.\n */\nfunction getModifierState(event: KeyboardEvent, mod: string) {\n\treturn typeof event.getModifierState === \"function\"\n\t\t? event.getModifierState(mod) ||\n\t\t\t\t(ALT_GRAPH_ALIASES.includes(mod) && event.getModifierState(\"AltGraph\"))\n\t\t: false\n}\n\n/**\n * Parses a \"Key Binding String\" into its parts\n *\n * grammar = `<sequence>`\n * <sequence> = `<press> <press> <press> ...`\n * <press> = `<key>` or `<mods>+<key>`\n * <mods> = `<mod>+<mod>+...`\n */\nexport function parseKeybinding(str: string): KeyBindingPress[] {\n\treturn str\n\t\t.trim()\n\t\t.split(\" \")\n\t\t.map(press => {\n\t\t\tlet mods = press.split(/\\b\\+/)\n\t\t\tlet key = mods.pop() as string\n\t\t\tmods = mods.map(mod => (mod === \"$mod\" ? MOD : mod))\n\t\t\treturn [mods, key]\n\t\t})\n}\n\n/**\n * This tells us if a series of events matches a key binding sequence either\n * partially or exactly.\n */\nfunction match(event: KeyboardEvent, press: KeyBindingPress): boolean {\n\t// prettier-ignore\n\treturn !(\n\t\t// Allow either the `event.key` or the `event.code`\n\t\t// MDN event.key: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key\n\t\t// MDN event.code: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code\n\t\t(\n\t\t\tpress[1].toUpperCase() !== event.key.toUpperCase() &&\n\t\t\tpress[1] !== event.code\n\t\t) ||\n\n\t\t// Ensure all the modifiers in the keybinding are pressed.\n\t\tpress[0].find(mod => {\n\t\t\treturn !getModifierState(event, mod)\n\t\t}) ||\n\n\t\t// KEYBINDING_MODIFIER_KEYS (Shift/Control/etc) change the meaning of a\n\t\t// keybinding. So if they are pressed but aren't part of the current\n\t\t// keybinding press, then we don't have a match.\n\t\tKEYBINDING_MODIFIER_KEYS.find(mod => {\n\t\t\treturn !press[0].includes(mod) && press[1] !== mod && getModifierState(event, mod
|
||
|
\ No newline at end of file
|
||
|
diff --git a/package.json b/package.json
|
||
|
index d6a93bb7cce03b4836cf96deba308de0417079a3..ce382afc534607d67b04d877cdf6990769c59d1b 100644
|
||
|
--- a/package.json
|
||
|
+++ b/package.json
|
||
|
@@ -7,7 +7,7 @@
|
||
|
"repository": "jamiebuilds/tinykeys",
|
||
|
"source": "src/tinykeys.ts",
|
||
|
"main": "dist/tinykeys.js",
|
||
|
- "module": "dist/tinykeys.module.js",
|
||
|
+ "module": "dist/tinykeys.module.mjs",
|
||
|
"unpkg": "dist/tinykeys.umd.js",
|
||
|
"types": "dist/tinykeys.d.ts",
|
||
|
"files": [
|
||
|
@@ -15,7 +15,7 @@
|
||
|
],
|
||
|
"exports": {
|
||
|
".": {
|
||
|
- "import": "./dist/tinykeys.module.js",
|
||
|
+ "import": "./dist/tinykeys.module.mjs",
|
||
|
"require": "./dist/tinykeys.js"
|
||
|
}
|
||
|
},
|