Skip to content

Commit

Permalink
release: 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Dec 20, 2023
1 parent 2184e48 commit 17cc3f1
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 12 deletions.
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.1.0",
"version": "0.2.0",
"minAppVersion": "1.3.5",
"description": "Enhance PDF viewer & embeds.",
"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.1.0",
"version": "0.2.0",
"description": "An Obsidian.md plugin to enhance PDF viewer & embeds.",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand Down
19 changes: 12 additions & 7 deletions src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ export const patchPDF = (plugin: PDFPlus): boolean => {
if (beginSelectionEl && endSelectionEl) {
height = endSelectionEl.getBoundingClientRect().bottom - beginSelectionEl.getBoundingClientRect().top;
height += plugin.settings.padding;
console.log({ height });
}
}

if (self.isEmbed && !self._zoomedIn) {
self._zoomedIn = true;
setTimeout(async () => {
for (let i = 0; i < plugin.settings.zoomInEmbed; i++) {
self.zoomIn();
await new Promise<void>((resolve) => {
setTimeout(resolve, 50);
})
}
}, 100);
}

old.call(this, height);
}
},
applySubpath(old) {
return function (subpath: string) {
console.log({ subpath });
return old.call(this, subpath);
}
}
}));

Expand Down
4 changes: 4 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export interface PDFPlusSettings {
trimSelectionEmbed: boolean;
padding: number;
embedUnscrollable: boolean;
zoomInEmbed: number;
}

export const DEFAULT_SETTINGS: PDFPlusSettings = {
alias: true,
trimSelectionEmbed: true,
padding: 80,
embedUnscrollable: false,
zoomInEmbed: 1
};

// Inspired by https://stackoverflow.com/a/50851710/13613783
Expand Down Expand Up @@ -120,6 +122,8 @@ export class PDFPlusSettingTab extends PluginSettingTab {
.setName('Trim selection embeds');
this.addToggleSetting('embedUnscrollable')
.setName('Make PDF embeds unscrollable');
this.addSliderSetting('zoomInEmbed', 0, 5, 1)
.setName('Zoom level for PDF embeds');

this.addDesc('You can find more options in Style Settings.')
.addButton((button) => {
Expand Down
2 changes: 2 additions & 0 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ interface ObsidianViewer {
isEmbed: boolean;
setHeight(height?: number | "page" | "auto"): void;
applySubpath(subpath: string): void;
zoomIn(): void;
_zoomedIn?: boolean;
}

interface AppSetting extends Modal {
Expand Down
17 changes: 16 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,24 @@ settings:
id: hide-pdf-embed-toolbar
title: Hide toolbar in PDF embeds with a page specified
type: class-toggle
default: true
-
id: pdf-embed-width
title: PDF embed width
type: variable-number-slider
min: 10
max: 200
step: 1
default: 100
*/

.hide-pdf-embed-toolbar .pdf-embed[src*="#"] .pdf-toolbar {
display: none;
}

.markdown-preview-view .pdf-embed,
.markdown-source-view.mod-cm6 .cm-content .pdf-embed {
margin-left: auto !important;
margin-right: auto !important;
width: calc(var(--pdf-embed-width) / 100 * 100%) !important;
}

0 comments on commit 17cc3f1

Please sign in to comment.