dsh-chat-link-actions 0.2.6 → 0.2.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.
Files changed (2) hide show
  1. package/client.js +22 -0
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -577,12 +577,29 @@ window.__ModuleLoader__.load({
577
577
 
578
578
  function onKeyDown(event) {
579
579
  if (open === null) return;
580
+ var typing = editableField(event.target) === true || (open.restoreFocus !== null && editableField(open.restoreFocus) === true);
580
581
  if (event.key === "Escape") {
581
582
  event.preventDefault();
582
583
  event.stopPropagation();
583
584
  closeMenu(true);
584
585
  return;
585
586
  }
587
+ if (typing && event.key !== "ArrowDown" && event.key !== "ArrowUp") {
588
+ /* 用户已经在打字,就当放弃了菜单,别抢键。 */
589
+ closeMenu(false);
590
+ return;
591
+ }
592
+ if (event.key === "Tab") {
593
+ closeMenu(false);
594
+ return;
595
+ }
596
+ if (event.key === "Home" || event.key === "End") {
597
+ event.preventDefault();
598
+ event.stopPropagation();
599
+ open.index = event.key === "Home" ? 0 : open.items.length - 1;
600
+ paintActive();
601
+ return;
602
+ }
586
603
  if (event.key === "ArrowDown" || event.key === "ArrowUp") {
587
604
  event.preventDefault();
588
605
  event.stopPropagation();
@@ -624,6 +641,8 @@ window.__ModuleLoader__.load({
624
641
  for (var i = 0; i < open.buttons.length; i += 1) {
625
642
  open.buttons[i].setAttribute("data-active", i === open.index ? "true" : "false");
626
643
  }
644
+ var active = open.buttons[open.index];
645
+ if (active !== undefined) open.panel.setAttribute("aria-activedescendant", active.id);
627
646
  }
628
647
 
629
648
  function buildMenu(path, items) {
@@ -631,6 +650,7 @@ window.__ModuleLoader__.load({
631
650
  panel.className = "dcla-menu";
632
651
  panel.setAttribute("role", "menu");
633
652
  panel.setAttribute("aria-label", strings().menu);
653
+ panel.setAttribute("aria-activedescendant", "dcla-item-0");
634
654
 
635
655
  var caption = document.createElement("div");
636
656
  caption.className = "dcla-path";
@@ -647,7 +667,9 @@ window.__ModuleLoader__.load({
647
667
  var button = document.createElement("button");
648
668
  button.type = "button";
649
669
  button.className = "dcla-item";
670
+ button.id = "dcla-item-" + position;
650
671
  button.setAttribute("role", "menuitem");
672
+ button.setAttribute("tabindex", "-1");
651
673
  button.setAttribute("data-active", position === 0 ? "true" : "false");
652
674
 
653
675
  var glyph = document.createElement("span");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-chat-link-actions",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Right-click actions on file links in the DSH transcript: quote the path into the composer, or reveal the file in the OS file manager. Menus are drawn in the app's own style, never the system one.",
5
5
  "type": "module",
6
6
  "main": "index.js",