Skip to content

Commit

Permalink
release: 0.39.8
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Mar 30, 2024
1 parent ffd988e commit 492b300
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 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.7",
"version": "0.39.8",
"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.7",
"version": "0.39.8",
"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.7",
"version": "0.39.8",
"description": "The most Obsidian-native PDF annotation tool ever.",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand Down
15 changes: 11 additions & 4 deletions src/lib/copy-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export class copyLinkLib extends PDFPlusLibSubmodule {
}

// TODO: A better, more concise function name 😅
writeHighlightAnnotationToSelectionIntoFileAndCopyLink(checking: boolean, templates: { copyFormat: string, displayTextFormat?: string}, colorName?: string, autoPaste?: boolean): boolean {
writeHighlightAnnotationToSelectionIntoFileAndCopyLink(checking: boolean, templates: { copyFormat: string, displayTextFormat?: string }, colorName?: string, autoPaste?: boolean): boolean {
// Get and store the selected text before writing file because
// the file modification will cause the PDF viewer to be reloaded,
// which will clear the selection.
Expand Down Expand Up @@ -753,7 +753,7 @@ export class copyLinkLib extends PDFPlusLibSubmodule {
const scrollInfo = editor.getScrollInfo();
if (coords.top < scrollInfo.top || coords.top > scrollInfo.top + scrollInfo.clientHeight) {
view.currentMode.applyScroll(line);
}
}
}
}

Expand Down Expand Up @@ -801,8 +801,15 @@ export class copyLinkLib extends PDFPlusLibSubmodule {
async autoFocusOrAutoPaste(evaluated: string, autoPaste?: boolean, palette?: ColorPalette) {
if (autoPaste || this.settings.autoPaste) {
const success = await this.autoPaste(evaluated);
if (success) palette?.setStatus('Link copied & pasted', this.statusDurationMs);
else palette?.setStatus('Link copied but paste target not identified', this.statusDurationMs);
if (success) {
palette?.setStatus('Link copied & pasted', this.statusDurationMs);
if (!this.settings.focusEditorAfterAutoPaste && this.settings.clearSelectionAfterAutoPaste) {
const selection = activeWindow.getSelection();
if (selection && this.lib.copyLink.getPageAndTextRangeFromSelection(selection)) {
selection.empty();
}
}
} else palette?.setStatus('Link copied but paste target not identified', this.statusDurationMs);
} else {
if (this.settings.autoFocus) {
const success = await this.autoFocus();
Expand Down
12 changes: 10 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export interface PDFPlusSettings {
clickOutlineItemWithModifierKey: boolean;
clickThumbnailWithModifierKey: boolean;
focusEditorAfterAutoPaste: boolean;
clearSelectionAfterAutoPaste: boolean;
respectCursorPositionWhenAutoPaste: boolean;
autoCopy: boolean;
autoFocus: boolean;
Expand Down Expand Up @@ -424,6 +425,7 @@ export const DEFAULT_SETTINGS: PDFPlusSettings = {
clickOutlineItemWithModifierKey: true,
clickThumbnailWithModifierKey: true,
focusEditorAfterAutoPaste: true,
clearSelectionAfterAutoPaste: true,
respectCursorPositionWhenAutoPaste: true,
autoCopy: false,
autoFocus: false,
Expand Down Expand Up @@ -2090,9 +2092,15 @@ export class PDFPlusSettingTab extends PluginSettingTab {
}
this.addDropdownSetting('autoPasteTarget', AUTO_FOCUS_TARGETS)
.setName('Target markdown file to paste links to');
this.addToggleSetting('focusEditorAfterAutoPaste')
.setName('Focus editor after pasting')
this.addToggleSetting('focusEditorAfterAutoPaste', () => this.events.trigger('update'))
.setName('Focus editor after auto-pasting')
.setDesc('If enabled, auto-paste will focus on the editor after pasting.');
this.showConditionally(
this.addToggleSetting('clearSelectionAfterAutoPaste')
.setName('Clear text selection after auto-pasting')
.setDesc('If enabled, the text selection in the PDF viewer will be automatically cleared after performing auto-pasting.'),
() => !this.plugin.settings.focusEditorAfterAutoPaste
);
this.addToggleSetting('respectCursorPositionWhenAutoPaste')
.setName('Respect current cursor position')
.setDesc('When enabled, the auto-paste command will paste the copied text at the current cursor position if the target note is already opened. If disabled, the text will be always appended to the end of the note.');
Expand Down

0 comments on commit 492b300

Please sign in to comment.