More fixes related to #363
This commit is contained in:
@@ -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