From aabc05d3b8c5705657bf71b56c03859600e6d97b Mon Sep 17 00:00:00 2001 From: RyotaUshio Date: Sat, 10 Aug 2024 18:44:00 +0900 Subject: [PATCH] release: 0.40.9 --- manifest-beta.json | 2 +- manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/bib.ts | 4 ++-- src/main.ts | 16 +++++++++++++++- src/patchers/pdf-internals.ts | 14 +++++++++++++- styles.css | 7 ++++++- 8 files changed, 41 insertions(+), 10 deletions(-) diff --git a/manifest-beta.json b/manifest-beta.json index a05c2c7d..d8abf2f9 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "pdf-plus", "name": "PDF++", - "version": "0.40.8", + "version": "0.40.9", "minAppVersion": "1.5.8", "description": "The most Obsidian-native PDF annotation tool ever.", "author": "Ryota Ushio", diff --git a/manifest.json b/manifest.json index a05c2c7d..d8abf2f9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "pdf-plus", "name": "PDF++", - "version": "0.40.8", + "version": "0.40.9", "minAppVersion": "1.5.8", "description": "The most Obsidian-native PDF annotation tool ever.", "author": "Ryota Ushio", diff --git a/package-lock.json b/package-lock.json index 6c3531c6..fdc95769 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-pdf-plus", - "version": "0.40.8", + "version": "0.40.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-pdf-plus", - "version": "0.40.8", + "version": "0.40.9", "license": "MIT", "devDependencies": { "@cantoo/pdf-lib": "^1.21.0", diff --git a/package.json b/package.json index 060ce676..5784ef4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-pdf-plus", - "version": "0.40.8", + "version": "0.40.9", "description": "The most Obsidian-native PDF annotation tool ever.", "scripts": { "dev": "node esbuild.config.mjs", diff --git a/src/bib.ts b/src/bib.ts index 7a61a75c..cd623b4d 100644 --- a/src/bib.ts +++ b/src/bib.ts @@ -212,7 +212,7 @@ export class BibliographyManager extends PDFPlusComponent { class BibliographyTextExtractor { doc: PDFDocumentProxy; pageRefToTextContentItemsPromise: Record | undefined>; - onExtractedCallback: (destId: string, bibText: string) => any; + onExtractedCallback?: (destId: string, bibText: string) => any; constructor(doc: PDFDocumentProxy) { this.doc = doc; @@ -235,7 +235,7 @@ class BibliographyTextExtractor { .then((bibInfo) => { if (bibInfo) { const bibText = bibInfo.text; - this.onExtractedCallback(destId, bibText); + this.onExtractedCallback?.(destId, bibText); } }) ); diff --git a/src/main.ts b/src/main.ts index 855bcd9c..d80254f0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -115,7 +115,16 @@ export default class PDFPlus extends Plugin { } async onunload() { - // Clean up the AnyStyle input files and their directory (.obsidian/plugins/pdf-plus/anystyle) + await this.cleanUpResources(); + } + + /** Perform clean-ups not registered explicitly. */ + async cleanUpResources() { + await this.cleanUpAnystyleFiles(); + } + + /** Clean up the AnyStyle input files and their directory (.obsidian/plugins/pdf-plus/anystyle) */ + async cleanUpAnystyleFiles() { const adapter = this.app.vault.adapter; if (Platform.isDesktopApp && adapter instanceof FileSystemAdapter) { const anyStyleInputDir = this.getAnyStyleInputDir(); @@ -563,6 +572,11 @@ export default class PDFPlus extends Plugin { this.vimrc = await this.app.vault.read(file); } })); + + // Clean up other resources when the app quits + this.registerEvent(this.app.workspace.on('quit', async () => { + await this.cleanUpResources(); + })); } registerOneTimeEvent(events: T, ...[evt, callback, ctx]: OverloadParameters) { diff --git a/src/patchers/pdf-internals.ts b/src/patchers/pdf-internals.ts index 41030313..2ad113bb 100644 --- a/src/patchers/pdf-internals.ts +++ b/src/patchers/pdf-internals.ts @@ -1,4 +1,4 @@ -import { Component, MarkdownRenderer, Notice, TFile, debounce, setIcon, setTooltip, Keymap, Menu, Platform } from 'obsidian'; +import { Component, MarkdownRenderer, Notice, TFile, debounce, setIcon, setTooltip, Keymap, Menu, Platform, requireApiVersion } from 'obsidian'; import { around } from 'monkey-around'; import { PDFDocumentProxy } from 'pdfjs-dist'; @@ -202,6 +202,18 @@ const patchPDFViewerChild = (plugin: PDFPlus, child: PDFViewerChild) => { } } + // Fix for the Obsidian core issue where the "find next" button in the find bar has a wrong icon + // https://forum.obsidian.md/t/duplicate-up-arrow-up-displayed-when-searching-a-pdf-inside-obsidian/84403/3 + const fixedApiVersion = '1.7.0'; + const findNextButtonEl = this.findBar?.findNextButtonEl; + const findNextIconEl = findNextButtonEl.firstElementChild; + + if (!requireApiVersion(fixedApiVersion) + && findNextIconEl + && findNextIconEl.matches('svg.lucide-arrow-up')) { + setIcon(findNextButtonEl, 'lucide-arrow-down'); + } + return ret; } diff --git a/styles.css b/styles.css index a6bd756d..c790d48b 100644 --- a/styles.css +++ b/styles.css @@ -530,6 +530,11 @@ body { padding: var(--size-4-3); font-size: var(--font-ui-medium); + /* Make text inside citation hover selectable (https://github.com/RyotaUshio/obsidian-pdf-plus/issues/252) */ + -moz-user-select: text; + -webkit-user-select: text; + user-select: text; + .bib-title { font-weight: bold; padding-bottom: var(--size-4-2); @@ -597,4 +602,4 @@ body { body.pdf-plus-vim-hint-inverted { --pdf-plus-vim-hint-color: var(--text-on-accent); --pdf-plus-vim-hint-background-color: hsl(var(--accent-h), var(--accent-s), var(--accent-l)); -} +} \ No newline at end of file