From 6622005aa34d52a710ab8a34d37d248cbdfd9c6f Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Mon, 30 Sep 2024 15:23:00 +0200 Subject: [PATCH] 0.8.17 Fix for #53 #76 --- manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/note.ts | 18 ++++++++++++------ versions.json | 35 ++--------------------------------- 5 files changed, 18 insertions(+), 43 deletions(-) diff --git a/manifest.json b/manifest.json index 49277d9..db29d5b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "share-note", "name": "Share Note", - "version": "0.8.16", + "version": "0.8.17", "minAppVersion": "0.15.0", "description": "Instantly share a note, with the full theme and content exactly like you see in Reading View. Data is shared encrypted by default, and only you and the person you send it to have the key.", "author": "Alan Grainger", diff --git a/package-lock.json b/package-lock.json index b1b63c0..c9a65f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "share-note", - "version": "0.8.16", + "version": "0.8.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "share-note", - "version": "0.8.16", + "version": "0.8.17", "license": "MIT", "dependencies": { "csso": "^5.0.5", diff --git a/package.json b/package.json index 6adb1bf..e22f11d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "share-note", - "version": "0.8.16", + "version": "0.8.17", "description": "Instantly share a note, with the full theme and content exactly like you see in Reading View. Data is shared encrypted by default, and only you and the person you send it to have the key.", "main": "main.js", "scripts": { diff --git a/src/note.ts b/src/note.ts index 04c268b..04e5bb7 100644 --- a/src/note.ts +++ b/src/note.ts @@ -196,15 +196,21 @@ export default class Note { } // Replace links - for (const el of this.contentDom.querySelectorAll('a.internal-link')) { + for (const el of this.contentDom.querySelectorAll('a.internal-link, a.footnote-link')) { const href = el.getAttribute('href') const match = href ? href.match(/^([^#]+)/) : null if (href?.match(/^#/)) { - // Anchor link to a document heading, we need to add custom Javascript to jump to that heading - const selector = `[data-heading="${href.slice(1)}"]` - if (this.contentDom.querySelectorAll(selector)?.[0]) { - el.setAttribute('onclick', `document.querySelectorAll('${selector}')[0].scrollIntoView(true)`) - } + // This is an Anchor link to a document heading, we need to add custom Javascript + // to jump to that heading rather than using the normal # link + const linkTypes = [ + `[data-heading="${href.slice(1)}"]`, // Links to a heading + `[id="${href.slice(1)}"]`, // Links to a footnote + ] + linkTypes.forEach(selector => { + if (this.contentDom.querySelectorAll(selector)?.[0]) { + el.setAttribute('onclick', `document.querySelectorAll('${selector}')[0].scrollIntoView(true)`) + } + }) el.removeAttribute('target') el.removeAttribute('href') continue diff --git a/versions.json b/versions.json index fcc9d93..096fdd5 100644 --- a/versions.json +++ b/versions.json @@ -1,36 +1,4 @@ { - "0.5.0": "0.15.0", - "0.5.1": "0.15.0", - "0.5.2": "0.15.0", - "0.5.3": "0.15.0", - "0.5.4": "0.15.0", - "0.5.5": "0.15.0", - "0.5.6": "0.15.0", - "0.5.7": "0.15.0", - "0.5.8": "0.15.0", - "0.5.9": "0.15.0", - "0.5.10": "0.15.0", - "0.5.11": "0.15.0", - "0.5.12": "0.15.0", - "0.5.13": "0.15.0", - "0.5.14": "0.15.0", - "0.5.15": "0.15.0", - "0.5.16": "0.15.0", - "0.5.17": "0.15.0", - "0.5.18": "0.15.0", - "0.5.19": "0.15.0", - "0.5.20": "0.15.0", - "0.5.21": "0.15.0", - "0.5.22": "0.15.0", - "0.5.23": "0.15.0", - "0.5.24": "0.15.0", - "0.6.0": "0.15.0", - "0.6.1": "0.15.0", - "0.6.2": "0.15.0", - "0.6.3": "0.15.0", - "0.6.4": "0.15.0", - "0.7.0": "0.15.0", - "0.7.1": "0.15.0", "0.8.0": "0.15.0", "0.8.1": "0.15.0", "0.8.2": "0.15.0", @@ -47,5 +15,6 @@ "0.8.13": "0.15.0", "0.8.14": "0.15.0", "0.8.15": "0.15.0", - "0.8.16": "0.15.0" + "0.8.16": "0.15.0", + "0.8.17": "0.15.0" }