Skip to content

Commit

Permalink
release: 0.39.3
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Mar 24, 2024
1 parent 199119c commit def6a33
Show file tree
Hide file tree
Showing 17 changed files with 768 additions and 202 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.39.2",
"version": "0.39.3",
"minAppVersion": "1.4.16",
"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.39.2",
"version": "0.39.3",
"minAppVersion": "1.4.16",
"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.39.2",
"version": "0.39.3",
"description": "The most Obsidian-native PDF annotation tool ever.",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand Down
15 changes: 0 additions & 15 deletions src/auto-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,6 @@ export class AutoCopyMode extends PDFPlusComponent {
}

onload() {
this.lib.registerGlobalDomEvent(this, 'pointerup', () => {
if (activeWindow.getSelection()?.toString()) {
// const range = activeWindow.getSelection()?.getRangeAt(0);
// if (range) {
// const node = range.endContainer;
// const child = this.lib.getPDFViewerChildAssociatedWithNode(node);
// if (child) {
// const { right, bottom } = range.getBoundingClientRect();
// onContextMenu(this.plugin, child, new MouseEvent('contextmenu', { clientX: right, clientY: bottom }));
// }
// }
this.lib.commands.copyLink(false, false);
}
});

this.iconEl?.addClass('is-active');
}

Expand Down
15 changes: 13 additions & 2 deletions src/bib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { spawn } from 'child_process';

import PDFPlus from 'main';
import { PDFPlusComponent } from 'lib/component';
import { genId, onModKeyPress, toSingleLine } from 'utils';
import { genId, isCanvas, isEmbed, isHoverPopover, isNonEmbedLike, onModKeyPress, toSingleLine } from 'utils';
import { PDFViewerChild, PDFjsDestArray, TextContentItem } from 'typings';


Expand Down Expand Up @@ -35,8 +35,19 @@ export class BibliographyManager extends PDFPlusComponent {
this.init();
}

isEnabled() {
const viewer = this.child.pdfViewer;
return isNonEmbedLike(viewer)
|| (this.settings.enableBibInCanvas && isCanvas(viewer))
|| (this.settings.enableBibInHoverPopover && isHoverPopover(viewer))
|| (this.settings.enableBibInEmbed && isEmbed(viewer));
}

private async init() {
await this.initBibText().then(() => this.parseBibText());
if (this.isEnabled()) {
await this.initBibText();
await this.parseBibText();
}
this.initialized = true;
}

Expand Down
25 changes: 20 additions & 5 deletions src/color-palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ export class ColorPalette extends PDFPlusComponent {
const template = this.plugin.settings.copyCommands[this.actionIndex].template;

if (this.writeFile) {
this.lib.copyLink.writeHighlightAnnotationToSelectionIntoFileAndCopyLink(false, template, name ?? undefined);
this.lib.copyLink.writeHighlightAnnotationToSelectionIntoFileAndCopyLink(false, { copyFormat: template }, name ?? undefined);
} else {
this.lib.copyLink.copyLinkToSelection(false, template, name ?? undefined);
this.lib.copyLink.copyLinkToSelection(false, { copyFormat: template }, name ?? undefined);
}

evt.preventDefault();
Expand Down Expand Up @@ -229,7 +229,7 @@ export class ColorPalette extends PDFPlusComponent {
}

addCopyActionDropdown(paletteEl: HTMLElement) {
let tooltip = 'Color palette action options';
let tooltip = 'Link copy format';
if (!this.plugin.settings.colorPaletteInToolbar) {
tooltip = `${this.plugin.manifest.name}: link copy options (trigger via hotkeys)`
}
Expand Down Expand Up @@ -265,7 +265,7 @@ export class ColorPalette extends PDFPlusComponent {
paletteEl,
this.plugin.settings.displayTextFormats.map((format) => format.name),
'displayTextFormatIndex',
`${this.plugin.manifest.name}: Link display text format`,
`Display text format`,
() => {
if (this.plugin.settings.syncDisplayTextFormat && this.plugin.settings.syncDefaultDisplayTextFormat) {
this.plugin.settings.defaultDisplayTextFormatIndex = this.displayTextFormatIndex;
Expand All @@ -291,7 +291,7 @@ export class ColorPalette extends PDFPlusComponent {

this.writeFileButtonEl = paletteEl.createDiv('clickable-icon', (el) => {
setIcon(el, 'lucide-edit');
setTooltip(el, `${this.plugin.manifest.name}: Add ${this.plugin.settings.selectionBacklinkVisualizeStyle}s to file directly`);
setTooltip(el, `Add ${this.plugin.settings.selectionBacklinkVisualizeStyle}s to file directly`);
el.toggleClass('is-disabled', !this.lib.isEditable(this.child));

let shown = false;
Expand Down Expand Up @@ -634,6 +634,21 @@ export class ColorPalette extends PDFPlusComponent {
if (typeof state.writeFile === 'boolean') this.setWriteFile(state.writeFile);
}

getColorName(): string | null {
const state = this.getState();
return state.selectedColorName;
}

getCopyFormat(): string {
const state = this.getState();
return this.plugin.settings.copyCommands[state.actionIndex].template;
}

getDisplayTextFormat(): string {
const state = this.getState();
return this.plugin.settings.displayTextFormats[state.displayTextFormatIndex].template;
}

syncTo(palette: ColorPalette) {
const state: Partial<ColorPaletteState> = palette.getState();

Expand Down
Loading

0 comments on commit def6a33

Please sign in to comment.