Skip to content

Commit

Permalink
release: 0.40.9
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Aug 10, 2024
1 parent 7286944 commit aabc05d
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifest-beta.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/bib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class BibliographyManager extends PDFPlusComponent {
class BibliographyTextExtractor {
doc: PDFDocumentProxy;
pageRefToTextContentItemsPromise: Record<string, Promise<TextContentItem[]> | undefined>;
onExtractedCallback: (destId: string, bibText: string) => any;
onExtractedCallback?: (destId: string, bibText: string) => any;

constructor(doc: PDFDocumentProxy) {
this.doc = doc;
Expand All @@ -235,7 +235,7 @@ class BibliographyTextExtractor {
.then((bibInfo) => {
if (bibInfo) {
const bibText = bibInfo.text;
this.onExtractedCallback(destId, bibText);
this.onExtractedCallback?.(destId, bibText);
}
})
);
Expand Down
16 changes: 15 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<T extends Events>(events: T, ...[evt, callback, ctx]: OverloadParameters<T['on']>) {
Expand Down
14 changes: 13 additions & 1 deletion src/patchers/pdf-internals.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
}
}

0 comments on commit aabc05d

Please sign in to comment.