From 4b349ec99946df142605ed14932dcd3a422893d4 Mon Sep 17 00:00:00 2001 From: Davis Riedel Date: Tue, 20 Feb 2024 17:49:33 +0100 Subject: [PATCH] fix #8 --- main.ts | 11 ++++++++--- package.json | 14 +++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/main.ts b/main.ts index 93d3d2e..8c2bc3f 100644 --- a/main.ts +++ b/main.ts @@ -102,7 +102,13 @@ export default class Linkify extends Plugin { evt.target.className.includes("cm-link linkified")) { let m = this.matchRule(evt.target.innerText); if (m != null) { - window.open(m.link); + // try to match internal link + const internalLinkMatch = m.link.match(/^\[\[([^|\]]*)(?:\|[^|\]]*)?\]\]$/); + if (internalLinkMatch != null) { + this.app.workspace.openLinkText(internalLinkMatch.at(1), ""); + } else { + window.open(m.link); + } } } } @@ -149,8 +155,7 @@ export default class Linkify extends Plugin { // Converts matching text in the HTMLElement into links. markdownPostProcessor(el: HTMLElement) { if (el.firstChild instanceof Node) { - let walker = document.createTreeWalker( - el.firstChild, NodeFilter.SHOW_TEXT, null); + let walker = document.createTreeWalker(el.firstChild, NodeFilter.SHOW_TEXT, null); let nodes: Node[] = []; let node: Node; while (node = walker.nextNode()) { diff --git a/package.json b/package.json index adfcd73..cf0789f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "linkify", "version": "1.0.13", "description": "Turns strings into links.", - "main": "main.js", + "main": "main.js", "scripts": { "dev": "node esbuild.config.mjs", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", @@ -12,13 +12,13 @@ "author": "", "license": "MIT", "devDependencies": { - "@types/node": "^16.11.6", - "@typescript-eslint/eslint-plugin": "^5.2.0", - "@typescript-eslint/parser": "^5.2.0", - "builtin-modules": "^3.2.0", + "@types/node": "^20.11.19", + "@typescript-eslint/eslint-plugin": "^7.0.2", + "@typescript-eslint/parser": "^7.0.2", + "builtin-modules": "^3.3.0", "esbuild": "0.13.12", "obsidian": "latest", - "tslib": "2.3.1", - "typescript": "4.4.4" + "tslib": "2.6.2", + "typescript": "5.3.3" } }