dsh-chat-link-actions 0.2.9 → 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 +8 -6
- 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
|
}
|
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",
|