More fixes related to #363
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { asset, clientStore, editor, markdown, system } from "$sb/syscalls.ts";
|
||||
import { renderMarkdownToHtml } from "./markdown_render.ts";
|
||||
import { resolvePath } from "$sb/lib/resolve.ts";
|
||||
import { resolveAttachmentPath } from "$sb/lib/resolve.ts";
|
||||
import { expandCodeWidgets } from "./api.ts";
|
||||
import { folderName, resolve } from "../../common/path.ts";
|
||||
|
||||
export async function updateMarkdownPreview() {
|
||||
if (!(await clientStore.get("enableMarkdownPreview"))) {
|
||||
@@ -19,14 +18,9 @@ export async function updateMarkdownPreview() {
|
||||
const html = renderMarkdownToHtml(mdTree, {
|
||||
smartHardBreak: true,
|
||||
annotationPositions: true,
|
||||
translateUrls: (url, type) => {
|
||||
translateUrls: (url) => {
|
||||
if (!url.includes("://")) {
|
||||
if (type === "image" && !url.startsWith("/")) {
|
||||
// Make relative to current folder
|
||||
url = resolve(folderName(currentPage), decodeURI(url));
|
||||
} else if (type === "link") { // link
|
||||
url = resolvePath(currentPage, decodeURI(url), true);
|
||||
}
|
||||
url = resolveAttachmentPath(currentPage, decodeURI(url));
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user