dsh-chat-link-actions 0.2.16 → 0.2.17
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 +16 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -263,6 +263,8 @@ window.__ModuleLoader__.load({
|
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
/** An absolute path written as plain text inside the clicked element. */
|
|
266
|
+
var proseCandidate = false;
|
|
267
|
+
|
|
266
268
|
var PATH_IN_TEXT = /(?:^|[\s"'“”「」()()\[\]<>])(@?"?(?:\/|[A-Za-z]:[\\/]|\\\\[^\\\s]+\\|~\/(?!\/))[^\s"'“”「」<>,。;:!?()【】《》]*)/u;
|
|
267
269
|
|
|
268
270
|
/** 路径结尾成立的样子:有扩展名,或以分隔符收尾。 */
|
|
@@ -460,7 +462,10 @@ window.__ModuleLoader__.load({
|
|
|
460
462
|
if (fromFiber !== null) return fromFiber;
|
|
461
463
|
if (point !== null && point !== undefined && point.allowProse !== false) {
|
|
462
464
|
var fromCaret = pathFromCaret(point.x, point.y);
|
|
463
|
-
if (fromCaret !== null)
|
|
465
|
+
if (fromCaret !== null) {
|
|
466
|
+
proseCandidate = true;
|
|
467
|
+
return fromCaret;
|
|
468
|
+
}
|
|
464
469
|
}
|
|
465
470
|
return null;
|
|
466
471
|
}
|
|
@@ -987,13 +992,23 @@ window.__ModuleLoader__.load({
|
|
|
987
992
|
}
|
|
988
993
|
}
|
|
989
994
|
|
|
995
|
+
/** Prose needs a real path shape: /help and skill chips must stay native. */
|
|
996
|
+
function looksLikePath(value) {
|
|
997
|
+
var rest = value.replace(/^(?:[A-Za-z]:)?[\\/]+/u, "");
|
|
998
|
+
if (rest === "") return false;
|
|
999
|
+
if (/[\\/]/u.test(rest)) return true;
|
|
1000
|
+
return /\.[A-Za-z0-9]{1,8}$/u.test(rest);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
990
1003
|
function onContextMenu(event) {
|
|
991
1004
|
if (!(event.target instanceof Element)) return;
|
|
992
1005
|
var target = event.target;
|
|
993
1006
|
try {
|
|
994
1007
|
var inField = editableField(target);
|
|
1008
|
+
proseCandidate = false;
|
|
995
1009
|
var path = pathFromNode(target, { x: event.clientX, y: event.clientY, allowProse: !inField });
|
|
996
1010
|
if (path === null) return;
|
|
1011
|
+
if (proseCandidate && !looksLikePath(path)) return;
|
|
997
1012
|
openMenu(path, event.clientX, event.clientY, { inField: inField, directory: directoryHint(target) });
|
|
998
1013
|
event.preventDefault();
|
|
999
1014
|
event.stopPropagation();
|
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.17",
|
|
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",
|