UNPKG

@vericus/slate-kit-bind-hotkey

Version:

a slate helper plugin to associate hotkey(s) to slate change

2 lines (1 loc) 2.92 kB
!function(t,e){if("function"==typeof define&&define.amd)define(["exports","immutable","is-hotkey"],e);else if("undefined"!=typeof exports)e(exports,require("immutable"),require("is-hotkey"));else{var n={exports:{}};e(n.exports,t.immutable,t.isHotkey),t.unknown=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,e,n){var r;function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=i(t);if(e){var o=i(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return f(this,n)}}function a(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}t.__esModule=!0,t.default=void 0,n=(r=n)&&r.__esModule?r:{default:r};var l={hotkeys:void 0,commandName:void 0,commandArgs:void 0},p=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(n,t);var e=c(n);function n(){return o(this,n),e.apply(this,arguments)}return n}((0,e.Record)(l));function y(t){var e=t.hotkeys,r=t.commandName,o=t.commandArgs,i=Array.isArray(e)?e:[e];return function(t,e,u){return function(t){return i.some((function(e){return(0,n.default)(e)(t)}))}(t)&&e[r]?(t.preventDefault(),t.stopPropagation(),o?e[r].apply(e,a(o)):e[r](),!0):u()}}var d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new p(t),n=y(e);return{onKeyDown:n}};t.default=d}));