@taufik-nurrohman/text-editor.key 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -179,11 +179,13 @@
179
179
  var id = '_Key';
180
180
 
181
181
  function onBlur(e) {
182
- this[id].pull(); // Reset all key(s)
182
+ var $ = this;
183
+ $._event = e;
184
+ $[id].pull(); // Reset all key(s)
183
185
  }
184
186
 
185
187
  function onInput(e) {
186
- onBlur.call(this);
188
+ onBlur.call(this, e);
187
189
  }
188
190
 
189
191
  function onKeyDown(e) {
@@ -206,7 +208,9 @@
206
208
  }
207
209
 
208
210
  function onKeyUp(e) {
209
- this[id].pull(e.key); // Reset current key
211
+ var $ = this;
212
+ $._event = e;
213
+ $[id].pull(e.key); // Reset current key
210
214
  }
211
215
 
212
216
  function attach() {
package/index.min.js CHANGED
@@ -23,4 +23,4 @@
23
23
  * SOFTWARE.
24
24
  *
25
25
  */
26
- !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((n="undefined"!=typeof globalThis?globalThis:n||self).TextEditor=n.TextEditor||{},n.TextEditor.Key=t())}(this,(function(){"use strict";var n=function(n){return Array.isArray(n)},t=function(n){return"function"==typeof n},e=function(n,t){return void 0===t&&(t=!0),"object"==typeof n&&(!t||function(n,t){return n&&r(t)&&n instanceof t}(n,Object))},r=function(n){return function(n){return void 0!==n}(n)&&!function(n){return null===n}(n)},o=function(n){return"string"==typeof n},u=function t(){for(var o=arguments.length,u=Array(o),f=0;f<o;f++)u[f]=arguments[f];for(var c,s=u.shift(),a=0,l=i(u);a<l;++a)for(var y in u[a])if(r(s[y]))if(n(s[y])&&n(u[a][y])){s[y]=[].concat(s[y]);for(var d=0,p=i(u[a][y]);d<p;++d)c=u[a][y][d],-1===s[y].indexOf(c)&&s[y].push(u[a][y][d])}else e(s[y])&&e(u[a][y])?s[y]=t({},s[y],u[a][y]):s[y]=u[a][y];else s[y]=u[a][y];return s},i=function(n){return n.length};function f(n){var t=this;return t.commands={},t.key=null,t.keys={},t.queue={},t.self=n||t,t}var c=f.prototype;c.command=function(n){var t=this;if(o(n))return n===t.toString();var e=t.keys[t.toString()];return!!r(e)&&e},c.fire=function(e){var u,i,f=this,c=f.self||f;if(t(e))u=e.call(c),i=!0;else if(o(e)&&(e=f.commands[e]))u=e.call(c),i=!0;else if(n(e)){var s=e[1]||[];(e=f.commands[e[0]])&&(u=e.apply(c,s),i=!0)}return i?!r(u)||u:null},c.pull=function(n){var t=this;return t.key=null,r(n)?(delete t.queue[n],t):(t.queue={},t)},c.push=function(n){var t=this;return t.queue[t.key=n]=1,t},c.toString=function(){return(n=this.queue,Object.keys(n)).join("-");var n},Object.defineProperty(f,"name",{value:"Key"});var s,a,l,y=function(n){return n&&n.preventDefault()},d=function(n){return n&&n.stopPropagation()},p=(s=function(n){return n.pull()},a=1e3,function(){var n=arguments,t=this;l&&clearTimeout(l),l=setTimeout((function(){return s.apply(t,n)}),a)}),m="_Key";function h(n){this[m].pull()}function v(n){h.call(this)}function k(n){var t,e,r=this[m];r.push(n.key),this._event=n,(t=r.command())&&(!1===(e=r.fire(t))?(y(n),d(n)):null===e&&console.warn("Unknown command: `"+t+"`")),p(r)}function b(n){this[m].pull(n.key)}var g={attach:function(){var n=this,e=n.constructor.prototype,o=new f(n);return n.commands=u(n.commands=o.commands,n.state.commands||{}),n.keys=u(n.keys=o.keys,n.state.keys||{}),!t(e.command)&&(e.command=function(n,t){return this.commands[n]=t,this}),!t(e.k)&&(e.k=function(n){var t,e=this[m]+"";return r(n)&&"-"!==n&&(t=""!==e?e.split(/-(?!$)/):[],!1!==n)?t.join(n):!1===n?"-"===e?[e]:t:e}),!t(e.key)&&(e.key=function(n,t){return this.keys[n]=t,this}),n.on("blur",h),n.on("input",v),n.on("key.down",k),n.on("key.up",b),n[m]=o,n},detach:function(){var n=this;return n[m].pull(),n.off("blur",h),n.off("input",v),n.off("key.down",k),n.off("key.up",b),delete n[m],n},name:"TextEditor.Key"};return g}));
26
+ !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((n="undefined"!=typeof globalThis?globalThis:n||self).TextEditor=n.TextEditor||{},n.TextEditor.Key=t())}(this,(function(){"use strict";var n=function(n){return Array.isArray(n)},t=function(n){return"function"==typeof n},e=function(n,t){return void 0===t&&(t=!0),"object"==typeof n&&(!t||function(n,t){return n&&r(t)&&n instanceof t}(n,Object))},r=function(n){return function(n){return void 0!==n}(n)&&!function(n){return null===n}(n)},o=function(n){return"string"==typeof n},u=function t(){for(var o=arguments.length,u=Array(o),f=0;f<o;f++)u[f]=arguments[f];for(var c,s=u.shift(),a=0,l=i(u);a<l;++a)for(var y in u[a])if(r(s[y]))if(n(s[y])&&n(u[a][y])){s[y]=[].concat(s[y]);for(var d=0,p=i(u[a][y]);d<p;++d)c=u[a][y][d],-1===s[y].indexOf(c)&&s[y].push(u[a][y][d])}else e(s[y])&&e(u[a][y])?s[y]=t({},s[y],u[a][y]):s[y]=u[a][y];else s[y]=u[a][y];return s},i=function(n){return n.length};function f(n){var t=this;return t.commands={},t.key=null,t.keys={},t.queue={},t.self=n||t,t}var c=f.prototype;c.command=function(n){var t=this;if(o(n))return n===t.toString();var e=t.keys[t.toString()];return!!r(e)&&e},c.fire=function(e){var u,i,f=this,c=f.self||f;if(t(e))u=e.call(c),i=!0;else if(o(e)&&(e=f.commands[e]))u=e.call(c),i=!0;else if(n(e)){var s=e[1]||[];(e=f.commands[e[0]])&&(u=e.apply(c,s),i=!0)}return i?!r(u)||u:null},c.pull=function(n){var t=this;return t.key=null,r(n)?(delete t.queue[n],t):(t.queue={},t)},c.push=function(n){var t=this;return t.queue[t.key=n]=1,t},c.toString=function(){return(n=this.queue,Object.keys(n)).join("-");var n},Object.defineProperty(f,"name",{value:"Key"});var s,a,l,y=function(n){return n&&n.preventDefault()},d=function(n){return n&&n.stopPropagation()},p=(s=function(n){return n.pull()},a=1e3,function(){var n=arguments,t=this;l&&clearTimeout(l),l=setTimeout((function(){return s.apply(t,n)}),a)}),m="_Key";function h(n){this._event=n,this[m].pull()}function v(n){h.call(this,n)}function k(n){var t,e,r=this[m];r.push(n.key),this._event=n,(t=r.command())&&(!1===(e=r.fire(t))?(y(n),d(n)):null===e&&console.warn("Unknown command: `"+t+"`")),p(r)}function b(n){this._event=n,this[m].pull(n.key)}var g={attach:function(){var n=this,e=n.constructor.prototype,o=new f(n);return n.commands=u(n.commands=o.commands,n.state.commands||{}),n.keys=u(n.keys=o.keys,n.state.keys||{}),!t(e.command)&&(e.command=function(n,t){return this.commands[n]=t,this}),!t(e.k)&&(e.k=function(n){var t,e=this[m]+"";return r(n)&&"-"!==n&&(t=""!==e?e.split(/-(?!$)/):[],!1!==n)?t.join(n):!1===n?"-"===e?[e]:t:e}),!t(e.key)&&(e.key=function(n,t){return this.keys[n]=t,this}),n.on("blur",h),n.on("input",v),n.on("key.down",k),n.on("key.up",b),n[m]=o,n},detach:function(){var n=this;return n[m].pull(),n.off("blur",h),n.off("input",v),n.off("key.down",k),n.off("key.up",b),delete n[m],n},name:"TextEditor.Key"};return g}));
package/index.mjs CHANGED
@@ -10,11 +10,13 @@ const name = 'TextEditor.Key';
10
10
  const id = '_Key';
11
11
 
12
12
  function onBlur(e) {
13
- this[id].pull(); // Reset all key(s)
13
+ let $ = this;
14
+ $._event = e;
15
+ $[id].pull(); // Reset all key(s)
14
16
  }
15
17
 
16
18
  function onInput(e) {
17
- onBlur.call(this);
19
+ onBlur.call(this, e);
18
20
  }
19
21
 
20
22
  function onKeyDown(e) {
@@ -35,7 +37,9 @@ function onKeyDown(e) {
35
37
  }
36
38
 
37
39
  function onKeyUp(e) {
38
- this[id].pull(e.key); // Reset current key
40
+ let $ = this;
41
+ $._event = e;
42
+ $[id].pull(e.key); // Reset current key
39
43
  }
40
44
 
41
45
  function attach() {
package/package.json CHANGED
@@ -46,5 +46,5 @@
46
46
  "scripts": {
47
47
  "pack": "pack --clean=false --from=.factory --js-format=umd --js-name=TextEditor.Key --js-top='%(js.license)' --mjs=true --to=."
48
48
  },
49
- "version": "1.0.6"
49
+ "version": "1.0.7"
50
50
  }