dsh-chat-link-actions 0.2.15 → 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/client.js +16 -1
- package/package.json +1 -1
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",
|