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
+3 -9
View File
@@ -9,8 +9,7 @@ import { renderMarkdownToHtml } from "../../plugs/markdown/markdown_render.ts";
import { ParseTree } from "$sb/lib/tree.ts";
import { lezerToParseTree } from "../../common/markdown_parser/parse_tree.ts";
import type { Client } from "../client.ts";
import { resolvePath } from "$sb/lib/resolve.ts";
import { folderName, resolve } from "../../common/path.ts";
import { resolveAttachmentPath } from "$sb/lib/resolve.ts";
class TableViewWidget extends WidgetType {
constructor(
@@ -39,14 +38,9 @@ class TableViewWidget extends WidgetType {
// Annotate every element with its position so we can use it to put
// the cursor there when the user clicks on the table.
annotationPositions: true,
translateUrls: (url, type) => {
translateUrls: (url) => {
if (!url.includes("://")) {
if (type === "image" && !url.startsWith("/")) {
// Make relative to current folder
url = resolve(folderName(this.editor.currentPage!), decodeURI(url));
} else if (type === "link") { // link
url = resolvePath(this.editor.currentPage!, decodeURI(url), true);
}
url = resolveAttachmentPath(this.editor.currentPage!, decodeURI(url));
}
return url;