@xiee/utils 1.2.7 → 1.2.8

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.
@@ -6,6 +6,7 @@ kbd {
6
6
  border-radius: 0.25em;
7
7
  min-width: 1.5em;
8
8
  text-align: center;
9
+ margin-right: .15em;
9
10
  }
10
11
  kbd:hover {
11
12
  position: relative;
package/js/key-buttons.js CHANGED
@@ -1,7 +1,13 @@
1
1
  (function(d) {
2
+ const a1 = ['Enter', 'Up', 'Down', 'Left', 'Right'];
3
+ const a2 = ['↵', '↑', '↓', '←', '→'];
4
+ function drawArrows(x) {
5
+ a1.map((v, i) => x = x.replace(new RegExp('>' + v + '<', 'g'), ' title="' + v + (i ? ' Arrow' : '') + '">' + a2[i] + '<'));
6
+ return x;
7
+ }
2
8
  // 1. individual keys; 2. modifiers; 3. normal keys
3
- const k1 = 'Esc|Tab|Enter|PageUp|PageDown|Up|Down|Left|Right|' +
4
- Array(12).fill().map((v, i) => 'F' + (i + 1)).join('|'),
9
+ const k1 = 'Esc|Tab|PageUp|PageDown|Space|Delete|Home|End|PrtScr?|PrintScreen|' +
10
+ Array(12).fill().map((v, i) => 'F' + (i + 1)).concat(a1).join('|'),
5
11
  k2 = 'Ctrl|Control|Shift|Alt|Cmd|Command|fn',
6
12
  k3 = '[a-zA-Z0-9]|Click',
7
13
  r1 = new RegExp('^(' + k1 + '|' + k2 + ')$'),
@@ -11,7 +17,7 @@
11
17
  if (el.childElementCount > 0) return;
12
18
  let t = el.innerText;
13
19
  if (r1.test(t)) {
14
- el.outerHTML = '<kbd>' + t + '</kbd>';
20
+ el.outerHTML = drawArrows('<kbd>' + t + '</kbd>');
15
21
  return;
16
22
  }
17
23
  if (!r2.test(t)) return;
@@ -20,6 +26,6 @@
20
26
  t2 += t.replace(r3, '<kbd>$1</kbd>$2');
21
27
  t = t.replace(r3, '$3');
22
28
  }
23
- if (t === '') el.outerHTML = t2.replace(/ \+ $/, '');
29
+ if (t === '') el.outerHTML = drawArrows(t2.replace(/ \+ $/, ''));
24
30
  });
25
31
  })(document);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"