dsh-chat-link-actions 0.2.14 → 0.2.16
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/README.md +2 -2
- package/client.js +16 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
| 右键文件链接 | 做什么 |
|
|
10
10
|
| --- | --- |
|
|
11
11
|
| **引用到对话** | 插成输入框里的引用芯片(`(</> 文件名)`),和拖文件、`@` 选文件的结果一样 |
|
|
12
|
-
| **在文件管理器中查看** |
|
|
12
|
+
| **在文件管理器中查看** | 打开所在目录并选中这个文件;macOS 是访达、Windows 是资源管理器、Linux 是文件管理器,菜单文字三端一致 |
|
|
13
13
|
| **复制路径** | 绝对路径进剪贴板,直接粘给别的窗口 |
|
|
14
14
|
|
|
15
15
|
## 认哪些链接
|
|
16
16
|
|
|
17
|
-
右键不是只认一种写法,常见渲染都走同一条解析:`href` / `src` 里的 `?path=`(图片、附件卡片)、`data-path` 之类的绝对路径属性、`title`
|
|
17
|
+
右键不是只认一种写法,常见渲染都走同一条解析:`href` / `src` 里的 `?path=`(图片、附件卡片)、`data-path` 之类的绝对路径属性、`title` 里的路径(宿主自绘的文件链接、文件夹链接)、以及直接写在正文里的绝对路径(光标落在路径上才算),包括代码块里的 `file.cjs#L12`、`#L12-L20` 这类带行号的写法(行号不进路径)。只显示「图标 + 文件名」、DOM 里没有路径的芯片(图片链接、Markdown 图片)也能认:路径从渲染它的组件属性里取。Windows 的 `C:\...`、`C:/...`、UNC 共享路径、含空格与中文的路径同样能认;正文里带空格的路径整条引用,芯片写作 `@"…"`。网页链接、`~` 和 `./` 开头的相对路径不当成本机文件。目录链接插入后是文件夹芯片(名字以 `/` 收尾),即使链接末尾没有斜杠。
|
|
18
18
|
|
|
19
19
|
## 装
|
|
20
20
|
|
package/client.js
CHANGED
|
@@ -170,6 +170,20 @@ window.__ModuleLoader__.load({
|
|
|
170
170
|
/* ── resolving a file path out of the clicked node ──────────────────── */
|
|
171
171
|
|
|
172
172
|
/** Trim a candidate down to the bare file path a link carries. */
|
|
173
|
+
/** Drop sentence punctuation that followed the path in prose. */
|
|
174
|
+
function trimProsePunctuation(value) {
|
|
175
|
+
var text = value.replace(/[.,;:!?]+$/u, "");
|
|
176
|
+
while (text.length > 1 && (text.charAt(text.length - 1) === ")" || text.charAt(text.length - 1) === "]")) {
|
|
177
|
+
var open = text.charAt(text.length - 1) === ")" ? "(" : "[";
|
|
178
|
+
var close = text.charAt(text.length - 1);
|
|
179
|
+
var opens = text.split(open).length - 1;
|
|
180
|
+
var closes = text.split(close).length - 1;
|
|
181
|
+
if (closes <= opens) break;
|
|
182
|
+
text = text.slice(0, -1);
|
|
183
|
+
}
|
|
184
|
+
return text;
|
|
185
|
+
}
|
|
186
|
+
|
|
173
187
|
function normalizeCandidate(value) {
|
|
174
188
|
if (typeof value !== "string") return null;
|
|
175
189
|
var candidate = value.trim();
|
|
@@ -189,6 +203,7 @@ window.__ModuleLoader__.load({
|
|
|
189
203
|
}
|
|
190
204
|
if (/^[A-Za-z]:(?![\\/])/u.test(candidate)) candidate = candidate.slice(0, 2) + "/" + candidate.slice(2);
|
|
191
205
|
if (!/^(?:[A-Za-z]:[\\/]?|[\\/]{1,2})$/u.test(candidate)) candidate = candidate.replace(/[\\/]+$/u, "");
|
|
206
|
+
candidate = trimProsePunctuation(candidate);
|
|
192
207
|
return looksAbsolute(candidate) ? candidate : null;
|
|
193
208
|
}
|
|
194
209
|
|
|
@@ -251,7 +266,7 @@ window.__ModuleLoader__.load({
|
|
|
251
266
|
var PATH_IN_TEXT = /(?:^|[\s"'“”「」()()\[\]<>])(@?"?(?:\/|[A-Za-z]:[\\/]|\\\\[^\\\s]+\\|~\/(?!\/))[^\s"'“”「」<>,。;:!?()【】《》]*)/u;
|
|
252
267
|
|
|
253
268
|
/** 路径结尾成立的样子:有扩展名,或以分隔符收尾。 */
|
|
254
|
-
var PATH_TAIL = /(?:\.[A-Za-z0-9]{1,8}(?:#L\d+(?:-L?\d+)?(?::\d+)?)
|
|
269
|
+
var PATH_TAIL = /(?:\.[A-Za-z0-9]{1,8}(?:#L\d+(?:-L?\d+)?(?::\d+)?)?[.,;:!?)\]]*|#L\d+(?:-L?\d+)?(?::\d+)?|[\\/])$/u;
|
|
255
270
|
|
|
256
271
|
/** 一段词像不像同一路径的下一段:不以分隔符或盘符开头,也不带句子标点。 */
|
|
257
272
|
function continuesPath(word) {
|
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.16",
|
|
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",
|
|
@@ -48,5 +48,9 @@
|
|
|
48
48
|
"repository": {
|
|
49
49
|
"type": "git",
|
|
50
50
|
"url": "git+https://github.com/regrevia/dsh-chat-link-actions.git"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/regrevia/dsh-chat-link-actions#readme",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/regrevia/dsh-chat-link-actions/issues"
|
|
51
55
|
}
|
|
52
56
|
}
|