dsh-chat-link-actions 0.2.8 → 0.2.10
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 +18 -10
- package/index.js +6 -2
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -178,6 +178,8 @@ window.__ModuleLoader__.load({
|
|
|
178
178
|
if (candidate.length > 1 && /^["']/.test(candidate) && /["']$/.test(candidate)) {
|
|
179
179
|
candidate = candidate.slice(1, -1);
|
|
180
180
|
}
|
|
181
|
+
if (/^["'<]/u.test(candidate)) candidate = candidate.slice(1);
|
|
182
|
+
if (/>$/u.test(candidate)) candidate = candidate.slice(0, -1);
|
|
181
183
|
candidate = candidate.replace(/[.,;:!?,。;:!?]+$/u, "");
|
|
182
184
|
candidate = stripLineSuffix(candidate);
|
|
183
185
|
if (/^file:\/\//i.test(candidate)) {
|
|
@@ -245,7 +247,7 @@ window.__ModuleLoader__.load({
|
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
/** An absolute path written as plain text inside the clicked element. */
|
|
248
|
-
var PATH_IN_TEXT = /(?:^|[\s"'“”「」()()\[\]])(@?"?(?:\/|[A-Za-z]:[\\/]|\\\\[^\\\s]+\\|~\/(?!\/))[^\s"'“”「」<>,。;:!?]*)/u;
|
|
250
|
+
var PATH_IN_TEXT = /(?:^|[\s"'“”「」()()\[\]<>])(@?"?(?:\/|[A-Za-z]:[\\/]|\\\\[^\\\s]+\\|~\/(?!\/))[^\s"'“”「」<>,。;:!?]*)/u;
|
|
249
251
|
|
|
250
252
|
/** 路径结尾成立的样子:有扩展名,或以分隔符收尾。 */
|
|
251
253
|
var PATH_TAIL = /(?:\.[A-Za-z0-9]{1,8}|[\\/])$/u;
|
|
@@ -314,14 +316,14 @@ window.__ModuleLoader__.load({
|
|
|
314
316
|
var matcher = new RegExp(PATH_IN_TEXT.source, "gu");
|
|
315
317
|
var hit = null;
|
|
316
318
|
while ((hit = matcher.exec(data)) !== null) {
|
|
317
|
-
|
|
319
|
+
var captured = hit[1] === undefined ? hit[0] : hit[1];
|
|
320
|
+
var start = hit.index + hit[0].length - captured.length;
|
|
321
|
+
var joined = joinPathWords(captured, data.slice(start + captured.length));
|
|
322
|
+
bounds.push({ text: joined, start: start, end: start + joined.length });
|
|
318
323
|
if (hit[0].length === 0) matcher.lastIndex += 1;
|
|
319
324
|
}
|
|
320
325
|
for (var i = 0; i < bounds.length; i += 1) {
|
|
321
|
-
if (offset >= bounds[i].start && offset <= bounds[i].end)
|
|
322
|
-
var tail = data.slice(bounds[i].end);
|
|
323
|
-
return normalizeCandidate(joinPathWords(bounds[i].text, tail));
|
|
324
|
-
}
|
|
326
|
+
if (offset >= bounds[i].start && offset <= bounds[i].end) return normalizeCandidate(bounds[i].text);
|
|
325
327
|
}
|
|
326
328
|
return null;
|
|
327
329
|
}
|
|
@@ -488,7 +490,8 @@ window.__ModuleLoader__.load({
|
|
|
488
490
|
copiedPath: "已复制路径", // ui-copy-ignore
|
|
489
491
|
copiedQuote: "已复制引用", // ui-copy-ignore
|
|
490
492
|
missing: "目标文件不存在", // ui-copy-ignore
|
|
491
|
-
managerFailed: "无法打开文件管理器"
|
|
493
|
+
managerFailed: "无法打开文件管理器",
|
|
494
|
+
clipboardFailed: "剪贴板不可用" // ui-copy-ignore
|
|
492
495
|
},
|
|
493
496
|
en: { // ui-copy-ignore
|
|
494
497
|
menu: "File actions", // ui-copy-ignore
|
|
@@ -498,7 +501,8 @@ window.__ModuleLoader__.load({
|
|
|
498
501
|
copiedPath: "Path copied", // ui-copy-ignore
|
|
499
502
|
copiedQuote: "Reference copied", // ui-copy-ignore
|
|
500
503
|
missing: "File not found", // ui-copy-ignore
|
|
501
|
-
managerFailed: "Could not open the file manager"
|
|
504
|
+
managerFailed: "Could not open the file manager",
|
|
505
|
+
clipboardFailed: "Clipboard unavailable" // ui-copy-ignore
|
|
502
506
|
}
|
|
503
507
|
};
|
|
504
508
|
|
|
@@ -713,7 +717,9 @@ window.__ModuleLoader__.load({
|
|
|
713
717
|
if (inserted) return;
|
|
714
718
|
navigator.clipboard.writeText(referenceText(path)).then(function () {
|
|
715
719
|
toast(strings().copiedQuote);
|
|
716
|
-
}, function () {
|
|
720
|
+
}, function () {
|
|
721
|
+
toast(strings().clipboardFailed);
|
|
722
|
+
});
|
|
717
723
|
});
|
|
718
724
|
} },
|
|
719
725
|
{ id: "reveal", label: strings().reveal, icon: "reveal", run: function () {
|
|
@@ -722,7 +728,9 @@ window.__ModuleLoader__.load({
|
|
|
722
728
|
{ id: "copy", label: strings().copy, icon: "copy", run: function () {
|
|
723
729
|
navigator.clipboard.writeText(path).then(function () {
|
|
724
730
|
toast(strings().copiedPath);
|
|
725
|
-
}, function () {
|
|
731
|
+
}, function () {
|
|
732
|
+
toast(strings().clipboardFailed);
|
|
733
|
+
});
|
|
726
734
|
} }
|
|
727
735
|
];
|
|
728
736
|
|
package/index.js
CHANGED
|
@@ -121,8 +121,12 @@ export function revealCommand(path, platform = process.platform, facts = {}) {
|
|
|
121
121
|
case 'darwin':
|
|
122
122
|
if (isDirectory && !isSymbolicLink) return { command: 'open', args: [target] }
|
|
123
123
|
return { command: 'open', args: ['-R', target] }
|
|
124
|
-
case 'win32':
|
|
125
|
-
|
|
124
|
+
case 'win32': {
|
|
125
|
+
const spelled = windowsTarget(target)
|
|
126
|
+
/* explorer cannot /select a drive root; open the drive itself instead. */
|
|
127
|
+
if (/^[A-Za-z]:\\$/u.test(spelled)) return { command: 'explorer.exe', args: [spelled] }
|
|
128
|
+
return { command: 'explorer.exe', args: [encodeExplorerSelect(spelled)] }
|
|
129
|
+
}
|
|
126
130
|
case 'android':
|
|
127
131
|
return { command: 'termux-open', args: [directoryOf(target, platform)] }
|
|
128
132
|
default:
|
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.10",
|
|
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",
|