dsh-chat-link-actions 0.2.6 → 0.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.
- package/client.js +23 -0
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -179,6 +179,7 @@ window.__ModuleLoader__.load({
|
|
|
179
179
|
candidate = candidate.slice(1, -1);
|
|
180
180
|
}
|
|
181
181
|
candidate = candidate.replace(/[.,;:!?,。;:!?]+$/u, "");
|
|
182
|
+
candidate = stripLineSuffix(candidate);
|
|
182
183
|
if (/^file:\/\//i.test(candidate)) {
|
|
183
184
|
candidate = candidate.replace(/^file:\/\/(?:localhost)?/i, "");
|
|
184
185
|
candidate = decodePercent(candidate);
|
|
@@ -577,12 +578,29 @@ window.__ModuleLoader__.load({
|
|
|
577
578
|
|
|
578
579
|
function onKeyDown(event) {
|
|
579
580
|
if (open === null) return;
|
|
581
|
+
var typing = editableField(event.target) === true || (open.restoreFocus !== null && editableField(open.restoreFocus) === true);
|
|
580
582
|
if (event.key === "Escape") {
|
|
581
583
|
event.preventDefault();
|
|
582
584
|
event.stopPropagation();
|
|
583
585
|
closeMenu(true);
|
|
584
586
|
return;
|
|
585
587
|
}
|
|
588
|
+
if (typing && event.key !== "ArrowDown" && event.key !== "ArrowUp") {
|
|
589
|
+
/* 用户已经在打字,就当放弃了菜单,别抢键。 */
|
|
590
|
+
closeMenu(false);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (event.key === "Tab") {
|
|
594
|
+
closeMenu(false);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
if (event.key === "Home" || event.key === "End") {
|
|
598
|
+
event.preventDefault();
|
|
599
|
+
event.stopPropagation();
|
|
600
|
+
open.index = event.key === "Home" ? 0 : open.items.length - 1;
|
|
601
|
+
paintActive();
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
586
604
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
587
605
|
event.preventDefault();
|
|
588
606
|
event.stopPropagation();
|
|
@@ -624,6 +642,8 @@ window.__ModuleLoader__.load({
|
|
|
624
642
|
for (var i = 0; i < open.buttons.length; i += 1) {
|
|
625
643
|
open.buttons[i].setAttribute("data-active", i === open.index ? "true" : "false");
|
|
626
644
|
}
|
|
645
|
+
var active = open.buttons[open.index];
|
|
646
|
+
if (active !== undefined) open.panel.setAttribute("aria-activedescendant", active.id);
|
|
627
647
|
}
|
|
628
648
|
|
|
629
649
|
function buildMenu(path, items) {
|
|
@@ -631,6 +651,7 @@ window.__ModuleLoader__.load({
|
|
|
631
651
|
panel.className = "dcla-menu";
|
|
632
652
|
panel.setAttribute("role", "menu");
|
|
633
653
|
panel.setAttribute("aria-label", strings().menu);
|
|
654
|
+
panel.setAttribute("aria-activedescendant", "dcla-item-0");
|
|
634
655
|
|
|
635
656
|
var caption = document.createElement("div");
|
|
636
657
|
caption.className = "dcla-path";
|
|
@@ -647,7 +668,9 @@ window.__ModuleLoader__.load({
|
|
|
647
668
|
var button = document.createElement("button");
|
|
648
669
|
button.type = "button";
|
|
649
670
|
button.className = "dcla-item";
|
|
671
|
+
button.id = "dcla-item-" + position;
|
|
650
672
|
button.setAttribute("role", "menuitem");
|
|
673
|
+
button.setAttribute("tabindex", "-1");
|
|
651
674
|
button.setAttribute("data-active", position === 0 ? "true" : "false");
|
|
652
675
|
|
|
653
676
|
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.
|
|
3
|
+
"version": "0.2.8",
|
|
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",
|