diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f845af..19335a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.23.0 (2025-02-04) +- Added support for wikilinks in the `a` function. You can now use markdown links in your queries. +- Improved how links are being rendered. Now using native links with the preview on hover + # 0.22.3 (2025-02-04) - Ability to enable / disable query refreshing individually for each query (REFRESH / NO REFRESH statement) - (Advanced) Added ability to show SQL execution plan for the query diff --git a/manifest.json b/manifest.json index c91e091..0169cb7 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "sqlseal", "name": "SQLSeal", - "version": "0.22.3", + "version": "0.23.0", "minAppVersion": "0.15.0", "description": "Use SQL in your notes to query your vault files and CSV content.", "author": "hypersphere", diff --git a/package.json b/package.json index 7ae207d..635b4c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sqlseal", - "version": "0.22.3", + "version": "0.23.0", "description": "A plugin for Obsidian that allows you to run SQL queries on your notes.", "main": "main.js", "scripts": { diff --git a/src/utils/ui.ts b/src/utils/ui.ts index 6a19685..95f5a40 100644 --- a/src/utils/ui.ts +++ b/src/utils/ui.ts @@ -1,4 +1,4 @@ -import { App } from "obsidian" +import { App, getLinkpath, parseLinktext } from "obsidian" import { CellParserRegistar } from "src/cellParser" export const displayNotice = (el: HTMLElement, text: string) => { @@ -13,6 +13,8 @@ export const displayError = (el: HTMLElement, text: string) => { const isLinkLocal = (link: string) => !link?.trim().startsWith('http') +const isLinktext = (link: string) => link.startsWith('[[') && link.endsWith(']]') + const renderCheckbox = (app: App) => ([value]: [string]) => { const el = createEl('input', { @@ -30,16 +32,32 @@ const renderLink = (app: App) => ([name, href]: [string, string]) => { if (!href) { href = name } - if (isLinkLocal(href)) { + href = href.trim() + let cls = '' + if (isLinktext(href)) { + const [path, linkName] = href.slice(2, -2).split('|') + const link = app.metadataCache.getFirstLinkpathDest(path, '') + + if (name.trim() === href) { + name = linkName ?? path + } + + if (!link) { + href = path + } else { + href = link.path + } + cls = 'internal-link' + + } else if (isLinkLocal(href)) { let fileHref = href if (fileHref.endsWith('.md')) { fileHref = fileHref.slice(0, -3) } - const vaultName = encodeURIComponent((app as any).appId); - const encodedPath = encodeURIComponent(fileHref); - href = `obsidian://open?vault=${vaultName}&file=${encodedPath}`; + href = href + cls = 'internal-link' } - const el = createEl('a', { text: name, href: href }) + const el = createEl('a', { text: name, href, cls }) return el } diff --git a/versions.json b/versions.json index 410eeca..9126238 100644 --- a/versions.json +++ b/versions.json @@ -39,5 +39,6 @@ "0.22.0": "0.15.0", "0.22.1": "0.15.0", "0.22.2": "0.15.0", - "0.22.3": "0.15.0" + "0.22.3": "0.15.0", + "0.23.0": "0.15.0" } \ No newline at end of file