Skip to content

Commit

Permalink
release: 0.38.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Mar 17, 2024
1 parent 66b335b commit 1070dbc
Show file tree
Hide file tree
Showing 27 changed files with 764 additions and 358 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.38.0-beta3",
"version": "0.38.0",
"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.37.16",
"version": "0.38.0",
"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.37.16",
"version": "0.38.0",
"description": "The most Obsidian-native PDF annotation tool ever.",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand Down
3 changes: 3 additions & 0 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ if __name__ == '__main__':
exit(1)

manifest['version'] = args.version
manifest_beta['version'] = args.version
package['version'] = args.version

with open('./manifest.json', 'w') as f:
json.dump(manifest, f, indent=4)
with open('./manifest-beta.json', 'w') as f:
json.dump(manifest, f, indent=4)
with open('./package.json', 'w') as f:
json.dump(package, f, indent=4)

Expand Down
48 changes: 48 additions & 0 deletions src/auto-copy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import PDFPlus from 'main';
import { PDFPlusComponent } from 'lib/component';


export class AutoCopyMode extends PDFPlusComponent {
iconEl: HTMLElement | null;

constructor(plugin: PDFPlus) {
super(plugin);
if (this.settings.autoCopyToggleRibbonIcon) {
this.iconEl = plugin.settings.autoCopyToggleRibbonIcon
? plugin.addRibbonIcon(
this.settings.autoCopyIconName,
`${plugin.manifest.name}: Toggle auto-copy`,
() => this.toggle()
) : null;
}
}

toggle(enable?: boolean) {
enable = enable ?? !this.settings.autoCopy;
enable ? this.enable() : this.disable();
}

enable() {
this.settings.autoCopy = true;
this.load();
}

disable() {
this.settings.autoCopy = false;
this.unload();
}

onload() {
this.lib.registerGlobalDomEvent(this, 'pointerup', () => {
if (activeWindow.getSelection()?.toString()) {
this.lib.commands.copyLink(false, false);
}
});

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

onunload() {
this.iconEl?.removeClass('is-active');
}
}
19 changes: 9 additions & 10 deletions src/backlink-visualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,29 @@ export class BacklinkDomManager extends PDFPlusComponent {
}

hookBacklinkOpeners(el: HTMLElement, cache: PDFBacklinkCache) {
const lineNumber = 'position' in cache.refCache ? cache.refCache.position.start.line : undefined;
const pos = 'position' in cache.refCache ? cache.refCache.position : undefined;
const lineNumber = pos?.start.line;

const state: any = { isTriggeredFromBacklinkVisualizer: true };
if (typeof lineNumber === 'number') {
state.scroll = lineNumber;
}
this.registerDomEvent(el, 'mouseover', (event) => {
this.app.workspace.trigger('hover-link', {
event,
source: 'pdf-plus',
hoverParent: this,
hoverParent: this.visualizer,
targetEl: el,
linktext: cache.sourcePath,
sourcePath: this.file.path,
state: typeof lineNumber === 'number' ? { scroll: lineNumber } : undefined
state
});
});

this.registerDomEvent(el, 'dblclick', (event) => {
if (this.plugin.settings.doubleClickHighlightToOpenBacklink) {
const paneType = Keymap.isModEvent(event);
if (paneType) {
this.app.workspace.openLinkText(cache.sourcePath, this.file.path, paneType, {
eState: typeof lineNumber === 'number' ? { scroll: lineNumber, line: lineNumber } : undefined
});
return;
}
this.lib.workspace.openMarkdownLinkFromPDF(cache.sourcePath, this.file.path, lineNumber);
this.lib.workspace.openMarkdownLinkFromPDF(cache.sourcePath, this.file.path, paneType, pos ? { pos } : undefined);
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/color-palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ export class ColorPalette extends PDFPlusComponent {
if (this.cropButtonEl) {
paletteEl.insertAfter(this.writeFileButtonEl, this.cropButtonEl);
}

this.setWriteFile(this.writeFile);
}

removeWriteFileToggle() {
Expand Down
2 changes: 1 addition & 1 deletion src/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ export class PDFPlusContextMenu extends Menu {
this.addItem((item) => {
item.setSection('search')
.setTitle('Copy link to search')
.setIcon('lucide-copy')
.setIcon('lucide-search')
.onClick(() => {
lib.copyLink.copyLinkToSearch(false, child, pageNumber, selectedText.trim());
});
Expand Down
21 changes: 13 additions & 8 deletions src/lib/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ export class PDFPlusCommands extends PDFPlusLibSubmodule {
checkCallback: (checking) => this.setWriteFile(checking, false)
}, {
id: 'toggle-auto-focus',
name: 'Toggle auto focus',
name: 'Toggle auto-focus',
callback: () => this.toggleAutoFocus()
}, {
id: 'toggle-select-to-copy',
name: 'Toggle "select text to copy" mode',
callback: () => this.plugin.selectToCopyMode.toggle()
id: 'toggle-auto-paste',
name: 'Toggle auto-paste',
callback: () => this.toggleAutoPaste()
}, {
id: 'toggle-auto-copy',
name: 'Toggle auto-copy',
callback: () => this.plugin.autoCopyMode.toggle()
}, {
id: 'add-page',
name: 'Add new page at the end',
Expand Down Expand Up @@ -473,10 +477,11 @@ export class PDFPlusCommands extends PDFPlusLibSubmodule {
}

toggleAutoFocus() {
const iconEl = this.plugin.autoFocusToggleIconEl;
iconEl.toggleClass('is-active', !iconEl.hasClass('is-active'));
this.settings.autoFocus = iconEl.hasClass('is-active');
this.plugin.saveSettings();
this.plugin.toggleAutoFocus();
}

toggleAutoPaste() {
this.plugin.toggleAutoPaste();
}

addPage(checking: boolean) {
Expand Down

0 comments on commit 1070dbc

Please sign in to comment.