@taufik-nurrohman/text-editor.key 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -4
- package/index.js +6 -2
- package/index.min.js +1 -1
- package/index.mjs +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
Text Editor Key
|
2
|
-
|
1
|
+
[Text Editor](https://github.com/taufik-nurrohman/text-editor) » Key
|
2
|
+
==========================================================================
|
3
3
|
|
4
|
-
|
4
|
+
Key extension for [Text Editor](https://github.com/taufik-nurrohman/text-editor). This extension provides a feature to
|
5
|
+
easily interact with the keyboard keys.
|
5
6
|
|
6
|
-
|
7
|
+
![index.js](https://img.shields.io/github/size/taufik-nurrohman/text-editor.key/index.js?branch=main&color=%23f1e05a&label=index.js&labelColor=%231f2328&style=flat-square)
|
8
|
+
![index.min.js](https://img.shields.io/github/size/taufik-nurrohman/text-editor.key/index.min.js?branch=main&color=%23f1e05a&label=index.min.js&labelColor=%231f2328&style=flat-square)
|
package/index.js
CHANGED
@@ -209,8 +209,12 @@
|
|
209
209
|
return $.commands[command] = of, $;
|
210
210
|
};
|
211
211
|
$.commands = fromStates(map.commands, $.state.commands || {});
|
212
|
-
$.k = function () {
|
213
|
-
|
212
|
+
$.k = function (join) {
|
213
|
+
var key = map + "";
|
214
|
+
if (!join || '-' === join) {
|
215
|
+
return key;
|
216
|
+
}
|
217
|
+
return key.split(/(?<!-)-/).join(join);
|
214
218
|
};
|
215
219
|
$.key = function (key, of) {
|
216
220
|
return $.keys[key] = of, $;
|
package/index.min.js
CHANGED
@@ -23,4 +23,4 @@
|
|
23
23
|
* SOFTWARE.
|
24
24
|
*
|
25
25
|
*/
|
26
|
-
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((n="undefined"!=typeof globalThis?globalThis:n||self).TextEditor=n.TextEditor||{},n.TextEditor.Key=e())}(this,(function(){"use strict";var n=function(n){return Array.isArray(n)},e=function(n){return"function"==typeof n},t=function(n,e){return void 0===e&&(e=!0),"object"==typeof n&&(!e||function(n,e){return n&&r(e)&&n instanceof e}(n,Object))},r=function(n){return function(n){return void 0!==n}(n)&&!function(n){return null===n}(n)},
|
26
|
+
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((n="undefined"!=typeof globalThis?globalThis:n||self).TextEditor=n.TextEditor||{},n.TextEditor.Key=e())}(this,(function(){"use strict";var n=function(n){return Array.isArray(n)},e=function(n){return"function"==typeof n},t=function(n,e){return void 0===e&&(e=!0),"object"==typeof n&&(!e||function(n,e){return n&&r(e)&&n instanceof e}(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 e(){for(var o=arguments.length,u=Array(o),f=0;f<o;f++)u[f]=arguments[f];for(var c,s=u.shift(),l=0,a=i(u);l<a;++l)for(var d in u[l])if(r(s[d]))if(n(s[d])&&n(u[l][d])){s[d]=[].concat(s[d]);for(var y=0,m=i(u[l][d]);y<m;++y)c=u[l][d][y],-1===s[d].indexOf(c)&&s[d].push(u[l][d][y])}else t(s[d])&&t(u[l][d])?s[d]=e({},s[d],u[l][d]):s[d]=u[l][d];else s[d]=u[l][d];return s},i=function(n){return n.length},f=function(n){return Object.keys(n)};function c(t){var u=this,i={};return u.command=function(n){if(o(n))return n===u.toString();var e=u.keys[u.toString()];return!!r(e)&&e},u.commands={},u.fire=function(t){var i,f,c=u.self||u;if(e(t))i=t.call(c),f=!0;else if(o(t)&&(t=u.commands[t]))i=t.call(c),f=!0;else if(n(t)){var s=t[1]||[];(t=u.commands[t[0]])&&(i=t.apply(c,s),f=!0)}return f?!r(i)||i:null},u.key=null,u.keys={},u.pull=function(n){return u.key=null,r(n)?(delete i[n],u):(i={},u)},u.push=function(n){return i[u.key=n]=1,u},u.self=t,u.toString=function(){return f(i).join("-")},u}var s,l,a,d=function(n,e,t){e.removeEventListener(n,t)},y=function(n){return n&&n.preventDefault()},m=function(n,e,t,r){void 0===r&&(r=!1),e.addEventListener(n,t,r)},p=(s=function(n){return n.pull()},l=1e3,function(){var n=arguments,e=this;a&&clearTimeout(a),a=setTimeout((function(){return s.apply(e,n)}),l)});function v(n){this.Key.pull()}function h(n){this.Key.pull()}function k(n){var e,t,r=this.Key;r.push(n.key),(e=r.command())&&(!1===(t=r.fire(e))?y(n):null===t&&console.warn("Unknown command: `"+e+"`")),p(r)}function b(n){this.Key.pull(n.key)}return{attach:function(n){var e=this,t=new c(e);e.command=function(n,t){return e.commands[n]=t,e},e.commands=u(t.commands,e.state.commands||{}),e.k=function(n){var e=t+"";return n&&"-"!==n?e.split(/(?<!-)-/).join(n):e},e.key=function(n,t){return e.keys[n]=t,e},e.keys=u(t.keys,e.state.keys||{}),m("blur",n,v),m("input",n,h),m("keydown",n,k),m("keyup",n,b),n.Key=t},detach:function(n){delete this.commands,delete this.keys,delete n.Key,d("blur",n,v),d("input",n,h),d("keydown",n,k),d("keyup",n,b)}}}));
|
package/index.mjs
CHANGED
@@ -36,7 +36,13 @@ function attach(self) {
|
|
36
36
|
let map = new Key($);
|
37
37
|
$.command = (command, of) => (($.commands[command] = of), $);
|
38
38
|
$.commands = fromStates(map.commands, $.state.commands || {});
|
39
|
-
$.k =
|
39
|
+
$.k = join => {
|
40
|
+
let key = map + "";
|
41
|
+
if (!join || '-' === join) {
|
42
|
+
return key;
|
43
|
+
}
|
44
|
+
return key.split(/(?<!-)-/).join(join);
|
45
|
+
};
|
40
46
|
$.key = (key, of) => (($.keys[key] = of), $);
|
41
47
|
$.keys = fromStates(map.keys, $.state.keys || {});
|
42
48
|
onEvent('blur', self, onBlur);
|
package/package.json
CHANGED