dsh-chat-link-actions 0.2.18 → 0.2.20
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 +20 -3
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -281,6 +281,20 @@ window.__ModuleLoader__.load({
|
|
|
281
281
|
* `C:\Users\apple\Desktop\a b.md` 这类带空格的路径,正则只吃到第一个空格。
|
|
282
282
|
* 往后最多接三段,取「结尾仍然像一个路径」的最长一段。
|
|
283
283
|
*/
|
|
284
|
+
/** 往后看两段,判断中文词后面是否跟着文件名。 */
|
|
285
|
+
function nextWordsLookLikeFile(rest) {
|
|
286
|
+
var probe = rest;
|
|
287
|
+
for (var round = 0; round < 2; round += 1) {
|
|
288
|
+
var space = /^[ \t]+/u.exec(probe);
|
|
289
|
+
if (space === null) return false;
|
|
290
|
+
var word = /^[^ \t"'“”「」<>,。;:!?、()【】《》]+/u.exec(probe.slice(space[0].length));
|
|
291
|
+
if (word === null) return false;
|
|
292
|
+
if (/\.[A-Za-z0-9]{1,8}$/u.test(word[0])) return true;
|
|
293
|
+
probe = probe.slice(space[0].length + word[0].length);
|
|
294
|
+
}
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
|
|
284
298
|
function joinPathWords(text, rest) {
|
|
285
299
|
var best = text;
|
|
286
300
|
var remaining = rest;
|
|
@@ -291,8 +305,9 @@ window.__ModuleLoader__.load({
|
|
|
291
305
|
if (word === null) break;
|
|
292
306
|
remaining = remaining.slice(space[0].length + word[0].length);
|
|
293
307
|
if (!continuesPath(word[0])) break;
|
|
294
|
-
/*
|
|
295
|
-
|
|
308
|
+
/* 中文句子在路径后继续说话时,不要把后面的词吞进路径;
|
|
309
|
+
但后两段里出现扩展名,说明中文词其实是文件名的一部分。 */
|
|
310
|
+
if (/^[\u3400-\u9fff]+$/u.test(word[0]) && !/\.[A-Za-z0-9]{1,8}$/u.test(word[0]) && !nextWordsLookLikeFile(remaining)) break;
|
|
296
311
|
var joined = best + " " + word[0];
|
|
297
312
|
if (PATH_TAIL.test(joined)) best = joined;
|
|
298
313
|
else if (!PATH_TAIL.test(best)) {
|
|
@@ -358,7 +373,9 @@ window.__ModuleLoader__.load({
|
|
|
358
373
|
/** Strip the line suffix a Markdown file link carries (`path#L12`). */
|
|
359
374
|
function stripLineSuffix(value) {
|
|
360
375
|
if (typeof value !== "string") return value;
|
|
361
|
-
|
|
376
|
+
var trimmed = value.replace(/#L[0-9]+(?:-L?[0-9]+)?(?::[0-9]+)?$/u, "");
|
|
377
|
+
/* Windows 风格的 match:line 后缀(a.md:12)也当行号剥掉。 */
|
|
378
|
+
return trimmed.replace(/(\.[A-Za-z0-9]{1,8}):[0-9]+(?:-[0-9]+)?$/u, "$1");
|
|
362
379
|
}
|
|
363
380
|
|
|
364
381
|
/** Read the path a component's props carry, if any. */
|
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.20",
|
|
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",
|