dsh-chat-link-actions 0.2.17 → 0.2.19

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/client.js +18 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## 认哪些链接
16
16
 
17
- 右键不是只认一种写法,常见渲染都走同一条解析:`href` / `src` 里的 `?path=`(图片、附件卡片)、`data-path` 之类的绝对路径属性、`title` 里的路径(宿主自绘的文件链接、文件夹链接)、以及直接写在正文里的绝对路径(光标落在路径上才算),包括代码块里的 `file.cjs#L12`、`#L12-L20` 这类带行号的写法(行号不进路径)。只显示「图标 + 文件名」、DOM 里没有路径的芯片(图片链接、Markdown 图片)也能认:路径从渲染它的组件属性里取。Windows 的 `C:\...`、`C:/...`、UNC 共享路径、含空格与中文的路径同样能认;正文里带空格的路径整条引用,芯片写作 `@"…"`。网页链接、`~` 和 `./` 开头的相对路径不当成本机文件。目录链接插入后是文件夹芯片(名字以 `/` 收尾),即使链接末尾没有斜杠。
17
+ 右键不是只认一种写法,常见渲染都走同一条解析:`href` / `src` 里的 `?path=`(图片、附件卡片)、`data-path` 之类的绝对路径属性、`title` 里的路径(宿主自绘的文件链接、文件夹链接)、以及直接写在正文里的绝对路径(光标落在路径上才算),包括代码块里的 `file.cjs#L12`、`#L12-L20` 这类带行号的写法(行号不进路径)。只显示「图标 + 文件名」、DOM 里没有路径的芯片(图片链接、Markdown 图片)也能认:路径从渲染它的组件属性里取。Windows 的 `C:\...`、`C:/...`、UNC 共享路径、含空格与中文的路径同样能认;正文里带空格的路径整条引用,芯片写作 `@"…"`。网页链接、`~` 和 `./` 开头的相对路径不当成本机文件;正文里单独一个词(`/help` 这类斜杠命令)不弹菜单,带扩展名或带层级的路径才算。目录链接插入后是文件夹芯片(名字以 `/` 收尾),即使链接末尾没有斜杠。
18
18
 
19
19
  ## 装
20
20
 
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,6 +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;
308
+ /* 中文句子在路径后继续说话时,不要把后面的词吞进路径;
309
+ 但后两段里出现扩展名,说明中文词其实是文件名的一部分。 */
310
+ if (/^[\u3400-\u9fff]+$/u.test(word[0]) && !/\.[A-Za-z0-9]{1,8}$/u.test(word[0]) && !nextWordsLookLikeFile(remaining)) break;
294
311
  var joined = best + " " + word[0];
295
312
  if (PATH_TAIL.test(joined)) best = joined;
296
313
  else if (!PATH_TAIL.test(best)) {
@@ -994,6 +1011,7 @@ window.__ModuleLoader__.load({
994
1011
 
995
1012
  /** Prose needs a real path shape: /help and skill chips must stay native. */
996
1013
  function looksLikePath(value) {
1014
+ if (/^[A-Za-z]:[\\/]/u.test(value)) return true;
997
1015
  var rest = value.replace(/^(?:[A-Za-z]:)?[\\/]+/u, "");
998
1016
  if (rest === "") return false;
999
1017
  if (/[\\/]/u.test(rest)) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-chat-link-actions",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
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",