Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slate-hotkeys

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slate-hotkeys - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

83

dist/slate-hotkeys.js

@@ -326,30 +326,3 @@ (function (global, factory) {

/**
* DOM event matching rules.
*
* @type {Array}
*/
var EVENT_RULES = [['beforeinput', function (el) {
return 'onbeforeinput' in el;
}]];
/**
* Operating system matching rules.
*
* @type {Array}
*/
var OS_RULES = [['ios', /os ([\.\_\d]+) like mac os/i], // must be before the macos rule
['macos', /mac os x/i], ['android', /android/i], ['firefoxos', /mozilla\/[a-z\.\_\d]+ \((?:mobile)|(?:tablet)/i], ['windows', /windows\s*(?:nt)?\s*([\.\_\d]+)/i]];
var EVENTS = {};
var OS = void 0;
/**
* Run the matchers when in browser.
*/
if (isBrowser) {
var userAgent = window.navigator.userAgent;
var _iteratorNormalCompletion = true;

@@ -360,3 +333,2 @@ var _didIteratorError = false;

try {
for (var _iterator = BROWSER_RULES[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {

@@ -370,3 +342,3 @@ var _ref = _step.value;

if (regexp.test(userAgent)) {
if (regexp.test(window.navigator.userAgent)) {
break;

@@ -389,3 +361,16 @@ }

}
}
/**
* Operating system matching rules.
*
* @type {Array}
*/
var OS_RULES = [['ios', /os ([\.\_\d]+) like mac os/i], // must be before the macos rule
['macos', /mac os x/i], ['android', /android/i], ['firefoxos', /mozilla\/[a-z\.\_\d]+ \((?:mobile)|(?:tablet)/i], ['windows', /windows\s*(?:nt)?\s*([\.\_\d]+)/i]];
var os = void 0;
if (isBrowser) {
var _iteratorNormalCompletion2 = true;

@@ -404,4 +389,4 @@ var _didIteratorError2 = false;

if (_regexp.test(userAgent)) {
OS = _name;
if (_regexp.test(window.navigator.userAgent)) {
os = _name;
break;

@@ -424,6 +409,24 @@ }

}
}
var testEl = window.document.createElement('div');
testEl.contentEditable = true;
/**
* Feature matching rules.
*
* @type {Array}
*/
var FEATURE_RULES = [['inputeventslevel1', function (window) {
var event = window.InputEvent ? new InputEvent('input') : {};
var support = 'inputType' in event;
return support;
}], ['inputeventslevel2', function (window) {
var element = window.document.createElement('div');
element.contentEditable = true;
var support = 'onbeforeinput' in element;
return support;
}]];
var features = [];
if (isBrowser) {
var _iteratorNormalCompletion3 = true;

@@ -434,3 +437,3 @@ var _didIteratorError3 = false;

try {
for (var _iterator3 = EVENT_RULES[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
for (var _iterator3 = FEATURE_RULES[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var _ref5 = _step3.value;

@@ -441,5 +444,7 @@

var _name2 = _ref6[0];
var testFn = _ref6[1];
var test = _ref6[1];
EVENTS[_name2] = testFn(testEl);
if (test(window)) {
features.push(_name2);
}
}

@@ -462,4 +467,6 @@ } catch (err) {

var IS_IOS = OS === 'ios';
var IS_MAC = OS === 'macos';
var IS_IOS = os === 'ios';
var IS_MAC = os === 'macos';
var HAS_INPUT_EVENTS_LEVEL_1 = features.includes('inputeventslevel1');
var HAS_INPUT_EVENTS_LEVEL_2 = features.includes('inputeventslevel2');

@@ -466,0 +473,0 @@ /**

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.SlateHotkeys={})}(this,function(e){"use strict";var t,r,o=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});for(var r={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},o={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:"undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},n={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},a=1;a<20;a++)n["f"+a]=111+a;function i(e,t,r){!t||"byKey"in t||(r=t,t=null),Array.isArray(e)||(e=[e]);var o=e.map(function(e){return d(e,t)}),n=function(e){return o.some(function(t){return c(t,e)})};return null==r?n:n(r)}function d(e,t){var o=t&&t.byKey,n={},a=(e=e.replace("++","+add")).split("+"),i=a.length;for(var d in r)n[r[d]]=!1;var c=!0,s=!1,u=void 0;try{for(var y,p=a[Symbol.iterator]();!(c=(y=p.next()).done);c=!0){var w=y.value,m=w.endsWith("?");m&&(w=w.slice(0,-1));var h=f(w),v=r[h];1!=i&&v||(o?n.key=h:n.which=l(w)),v&&(n[v]=!m||null),1==i&&!v&&o&&(n.shiftKey=null)}}catch(e){s=!0,u=e}finally{try{!c&&p.return&&p.return()}finally{if(s)throw u}}return n}function c(e,t){for(var r in e){var o=e[r],n=void 0;if(null!=o&&((null!=(n="key"===r?t.key.toLowerCase():"which"==r?91==o&&93==t.which?91:t.which:t[r])||!1!==o)&&n!==o))return!1}return!0}function l(e){return e=f(e),n[e]||e.toUpperCase().charCodeAt(0)}function f(e){return e=e.toLowerCase(),e=o[e]||e}t.default=i,t.isHotkey=i,t.isCodeHotkey=function(e,t){return i(e,t)},t.isKeyHotkey=function(e,t){return i(e,{byKey:!0},t)},t.parseHotkey=d,t.compareHotkey=c,t.toKeyCode=l,t.toKeyName=f}(t={exports:{}},t.exports),t.exports);(r=o)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")&&r.default;o.isHotkey,o.isCodeHotkey;var n=o.isKeyHotkey,a=(o.parseHotkey,o.compareHotkey,o.toKeyCode,o.toKeyName,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}),i="object"===("undefined"==typeof window?"undefined":a(window))&&"object"===("undefined"==typeof document?"undefined":a(document))&&9===document.nodeType,d=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],o=!0,n=!1,a=void 0;try{for(var i,d=e[Symbol.iterator]();!(o=(i=d.next()).done)&&(r.push(i.value),!t||r.length!==t);o=!0);}catch(e){n=!0,a=e}finally{try{!o&&d.return&&d.return()}finally{if(n)throw a}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c={},l=void 0;if(i){var f=window.navigator.userAgent,s=!0,u=!1,y=void 0;try{for(var p,w=[["edge",/Edge\/([0-9\._]+)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)$/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+)\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["android",/Android\s([0-9\.]+)/],["safari",/Version\/([0-9\._]+).*Safari/]][Symbol.iterator]();!(s=(p=w.next()).done);s=!0){var m=d(p.value,2);m[0];if(m[1].test(f))break}}catch(e){u=!0,y=e}finally{try{!s&&w.return&&w.return()}finally{if(u)throw y}}var h=!0,v=!1,b=void 0;try{for(var k,x=[["ios",/os ([\.\_\d]+) like mac os/i],["macos",/mac os x/i],["android",/android/i],["firefoxos",/mozilla\/[a-z\.\_\d]+ \((?:mobile)|(?:tablet)/i],["windows",/windows\s*(?:nt)?\s*([\.\_\d]+)/i]][Symbol.iterator]();!(h=(k=x.next()).done);h=!0){var g=d(k.value,2),S=g[0];if(g[1].test(f)){l=S;break}}}catch(e){v=!0,b=e}finally{try{!h&&x.return&&x.return()}finally{if(v)throw b}}var K=window.document.createElement("div");K.contentEditable=!0;var C=!0,H=!1,O=void 0;try{for(var _,j=[["beforeinput",function(e){return"onbeforeinput"in e}]][Symbol.iterator]();!(C=(_=j.next()).done);C=!0){var B=d(_.value,2),F=B[0],L=B[1];c[F]=L(K)}}catch(e){H=!0,O=e}finally{try{!C&&j.return&&j.return()}finally{if(H)throw O}}}var P={bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"mod?+ctrl?+alt?+left",moveForward:"mod?+ctrl?+alt?+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",splitBlock:"shift?+enter",undo:"mod+z"},A={moveLineBackward:"opt+up",moveLineForward:"opt+down",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},E={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:"ctrl+y"},M={},$="ios"===l||"macos"===l,W=!$;[].concat(Object.keys(P)).concat(Object.keys(A)).concat(Object.keys(E)).forEach(function(e){var t="is"+e[0].toUpperCase()+e.slice(1);if(!M[t]){var r=P[e],o=A[e],a=E[e],i=r&&n(r),d=o&&n(o),c=a&&n(a);M[t]=function(e){return!(!i||!i(e))||(!!($&&d&&d(e))||!!(W&&c&&c(e)))}}}),e.default=M,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.SlateHotkeys={})}(this,function(e){"use strict";var t,r,o=(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});for(var r={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},o={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:"undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},n={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},a=1;a<20;a++)n["f"+a]=111+a;function i(e,t,r){!t||"byKey"in t||(r=t,t=null),Array.isArray(e)||(e=[e]);var o=e.map(function(e){return d(e,t)}),n=function(e){return o.some(function(t){return l(t,e)})};return null==r?n:n(r)}function d(e,t){var o=t&&t.byKey,n={},a=(e=e.replace("++","+add")).split("+"),i=a.length;for(var d in r)n[r[d]]=!1;var l=!0,s=!1,u=void 0;try{for(var y,p=a[Symbol.iterator]();!(l=(y=p.next()).done);l=!0){var w=y.value,m=w.endsWith("?");m&&(w=w.slice(0,-1));var v=f(w),h=r[v];1!=i&&h||(o?n.key=v:n.which=c(w)),h&&(n[h]=!m||null),1==i&&!h&&o&&(n.shiftKey=null)}}catch(e){s=!0,u=e}finally{try{!l&&p.return&&p.return()}finally{if(s)throw u}}return n}function l(e,t){for(var r in e){var o=e[r],n=void 0;if(null!=o&&((null!=(n="key"===r?t.key.toLowerCase():"which"==r?91==o&&93==t.which?91:t.which:t[r])||!1!==o)&&n!==o))return!1}return!0}function c(e){return e=f(e),n[e]||e.toUpperCase().charCodeAt(0)}function f(e){return e=e.toLowerCase(),e=o[e]||e}t.default=i,t.isHotkey=i,t.isCodeHotkey=function(e,t){return i(e,t)},t.isKeyHotkey=function(e,t){return i(e,{byKey:!0},t)},t.parseHotkey=d,t.compareHotkey=l,t.toKeyCode=c,t.toKeyName=f}(t={exports:{}},t.exports),t.exports);(r=o)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")&&r.default;o.isHotkey,o.isCodeHotkey;var n=o.isKeyHotkey,a=(o.parseHotkey,o.compareHotkey,o.toKeyCode,o.toKeyName,"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}),i="object"===("undefined"==typeof window?"undefined":a(window))&&"object"===("undefined"==typeof document?"undefined":a(document))&&9===document.nodeType,d=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],o=!0,n=!1,a=void 0;try{for(var i,d=e[Symbol.iterator]();!(o=(i=d.next()).done)&&(r.push(i.value),!t||r.length!==t);o=!0);}catch(e){n=!0,a=e}finally{try{!o&&d.return&&d.return()}finally{if(n)throw a}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();if(i){var l=!0,c=!1,f=void 0;try{for(var s,u=[["edge",/Edge\/([0-9\._]+)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)$/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+)\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["android",/Android\s([0-9\.]+)/],["safari",/Version\/([0-9\._]+).*Safari/]][Symbol.iterator]();!(l=(s=u.next()).done);l=!0){var y=d(s.value,2);y[0];if(y[1].test(window.navigator.userAgent))break}}catch(e){c=!0,f=e}finally{try{!l&&u.return&&u.return()}finally{if(c)throw f}}}var p=void 0;if(i){var w=!0,m=!1,v=void 0;try{for(var h,b=[["ios",/os ([\.\_\d]+) like mac os/i],["macos",/mac os x/i],["android",/android/i],["firefoxos",/mozilla\/[a-z\.\_\d]+ \((?:mobile)|(?:tablet)/i],["windows",/windows\s*(?:nt)?\s*([\.\_\d]+)/i]][Symbol.iterator]();!(w=(h=b.next()).done);w=!0){var k=d(h.value,2),x=k[0];if(k[1].test(window.navigator.userAgent)){p=x;break}}}catch(e){m=!0,v=e}finally{try{!w&&b.return&&b.return()}finally{if(m)throw v}}}var g=[["inputeventslevel1",function(e){return"inputType"in(e.InputEvent?new InputEvent("input"):{})}],["inputeventslevel2",function(e){var t=e.document.createElement("div");return t.contentEditable=!0,"onbeforeinput"in t}]],S=[];if(i){var K=!0,C=!1,H=void 0;try{for(var O,_=g[Symbol.iterator]();!(K=(O=_.next()).done);K=!0){var j=d(O.value,2),B=j[0];(0,j[1])(window)&&S.push(B)}}catch(e){C=!0,H=e}finally{try{!K&&_.return&&_.return()}finally{if(C)throw H}}}var F="ios"===p,E="macos"===p,A=(S.includes("inputeventslevel1"),S.includes("inputeventslevel2"),{bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"mod?+ctrl?+alt?+left",moveForward:"mod?+ctrl?+alt?+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",splitBlock:"shift?+enter",undo:"mod+z"}),L={moveLineBackward:"opt+up",moveLineForward:"opt+down",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},P={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:"ctrl+y"},M={},$=F||E,I=!$;[].concat(Object.keys(A)).concat(Object.keys(L)).concat(Object.keys(P)).forEach(function(e){var t="is"+e[0].toUpperCase()+e.slice(1);if(!M[t]){var r=A[e],o=L[e],a=P[e],i=r&&n(r),d=o&&n(o),l=a&&n(a);M[t]=function(e){return!(!i||!i(e))||(!!($&&d&&d(e))||!!(I&&l&&l(e)))}}}),e.default=M,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "slate-hotkeys",
"description": "A set of function to detect common keypresses in a platform-agnostic way",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",

@@ -17,3 +17,3 @@ "repository": "git://github.com/ianstormtaylor/slate.git",

"is-hotkey": "^0.1.3",
"slate-dev-environment": "^0.1.4"
"slate-dev-environment": "^0.1.5"
},

@@ -20,0 +20,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc