More fixes related to #363

This commit is contained in:
Zef Hemel
2023-12-19 17:55:11 +01:00
parent a5c7405a35
commit 30436d97ea
9 changed files with 70 additions and 31 deletions
+9 -4
View File
@@ -7,7 +7,7 @@ import {
nodeAtPos,
ParseTree,
} from "$sb/lib/tree.ts";
import { resolvePath } from "$sb/lib/resolve.ts";
import { resolveAttachmentPath, resolvePath } from "$sb/lib/resolve.ts";
async function actionClickOrActionEnter(
mdTree: ParseTree | null,
@@ -79,7 +79,9 @@ async function actionClickOrActionEnter(
return editor.flashNotification("Empty link, ignoring", "error");
}
if (url.indexOf("://") === -1 && !url.startsWith("mailto:")) {
return editor.openUrl(resolvePath(currentPage, decodeURI(url)));
return editor.openUrl(
resolveAttachmentPath(currentPage, decodeURI(url)),
);
} else {
await editor.openUrl(url);
}
@@ -93,8 +95,11 @@ async function actionClickOrActionEnter(
try {
const args = argsText ? JSON.parse(`[${argsText}]`) : [];
await system.invokeCommand(commandName, args);
} catch(e: any) {
await editor.flashNotification(`Error parsing command link arguments: ${e.message}`, "error");
} catch (e: any) {
await editor.flashNotification(
`Error parsing command link arguments: ${e.message}`,
"error",
);
}
break;
}