dsh-chat-link-actions 0.2.12 → 0.2.14

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 (2) hide show
  1. package/client.js +10 -5
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -188,6 +188,7 @@ window.__ModuleLoader__.load({
188
188
  if (/^\/[A-Za-z]:[\\/]/.test(candidate)) candidate = candidate.slice(1);
189
189
  }
190
190
  if (/^[A-Za-z]:(?![\\/])/u.test(candidate)) candidate = candidate.slice(0, 2) + "/" + candidate.slice(2);
191
+ if (!/^(?:[A-Za-z]:[\\/]?|[\\/]{1,2})$/u.test(candidate)) candidate = candidate.replace(/[\\/]+$/u, "");
191
192
  return looksAbsolute(candidate) ? candidate : null;
192
193
  }
193
194
 
@@ -332,7 +333,8 @@ window.__ModuleLoader__.load({
332
333
  var FIBER_KEY = /^__(?:reactFiber|reactInternalInstance)\$/;
333
334
 
334
335
  /** 可能带文件的属性名。 */
335
- var PROP_KEYS = ["destination", "path", "src", "href"];
336
+ var PROP_KEYS = ["destination", "path", "absolutePath", "filePath", "localPath", "assetPath", "sourcePath", "src", "href"];
337
+ var PROP_CONTAINERS = ["file", "asset", "attachment", "source", "item"];
336
338
 
337
339
  /** Strip the line suffix a Markdown file link carries (`path#L12`). */
338
340
  function stripLineSuffix(value) {
@@ -343,10 +345,13 @@ window.__ModuleLoader__.load({
343
345
  /** Read the path a component's props carry, if any. */
344
346
  function pathFromProps(props) {
345
347
  if (props === null || typeof props !== "object") return null;
346
- var file = props.file;
347
- if (file !== null && typeof file === "object") {
348
- var fromFile = normalizeCandidate(stripLineSuffix(file.path));
349
- if (fromFile !== null) return fromFile;
348
+ for (var c = 0; c < PROP_CONTAINERS.length; c += 1) {
349
+ var box = props[PROP_CONTAINERS[c]];
350
+ if (box === null || typeof box !== "object") continue;
351
+ for (var k = 0; k < PROP_KEYS.length; k += 1) {
352
+ var nested = normalizeCandidate(stripLineSuffix(box[PROP_KEYS[k]]));
353
+ if (nested !== null) return nested;
354
+ }
350
355
  }
351
356
  for (var i = 0; i < PROP_KEYS.length; i += 1) {
352
357
  var fromProp = normalizeCandidate(stripLineSuffix(props[PROP_KEYS[i]]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-chat-link-actions",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
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",