Skip to content

Commit

Permalink
release: 0.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Dec 24, 2023
1 parent 073420c commit ae0dcfe
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 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.9.3",
"version": "0.9.4",
"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.9.3",
"version": "0.9.4",
"description": "An Obsidian.md plugin to enhance PDF viewer & embeds.",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand Down
8 changes: 6 additions & 2 deletions src/color-palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ export class ColorPalette {

constructor(public plugin: PDFPlus, toolbarLeftEl: HTMLElement) {
this.app = plugin.app;
plugin.registerEl(toolbarLeftEl.createDiv('pdf-toolbar-spacer'));
this.paletteEl = plugin.registerEl(toolbarLeftEl.createEl('div', { cls: ColorPalette.CLS }));
this.itemEls = [];
this.action = plugin.settings.defaultColorPaletteAction;

if (!plugin.settings.colorPaletteInEmbedToolbar && toolbarLeftEl.closest('.pdf-embed')) return;

plugin.registerEl(toolbarLeftEl.createDiv('pdf-toolbar-spacer'));
this.paletteEl = plugin.registerEl(toolbarLeftEl.createEl('div', { cls: ColorPalette.CLS }));


for (const [name, color] of Object.entries(plugin.settings.colors)) {
if (!isHexString(color)) continue;

Expand Down
3 changes: 2 additions & 1 deletion src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export const patchPDF = (plugin: PDFPlus): boolean => {
reset(old) {
return function () {
const self = this as PDFToolbar;
new ColorPalette(plugin, self.toolbarLeftEl);
// without setTimeout, the colorPaletteInEmbedToolbar option doesn't work for newly opened notes with PDF embeds
setTimeout(() => new ColorPalette(plugin, self.toolbarLeftEl));
old.call(this);
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface PDFPlusSettings {
colors: Record<string, HexString>;
defaultColor: string;
colorPaletteInToolbar: boolean;
colorPaletteInEmbedToolbar: boolean;
highlightColorSpecifiedOnly: boolean;
doubleClickHighlightToOpenBacklink: boolean;
hoverHighlightAction: keyof typeof HOVER_HIGHLIGHT_ACTIONS;
Expand Down Expand Up @@ -69,6 +70,7 @@ export const DEFAULT_SETTINGS: PDFPlusSettings = {
},
defaultColor: '',
colorPaletteInToolbar: true,
colorPaletteInEmbedToolbar: false,
highlightColorSpecifiedOnly: false,
doubleClickHighlightToOpenBacklink: true,
hoverHighlightAction: 'open',
Expand Down Expand Up @@ -329,12 +331,19 @@ export class PDFPlusSettingTab extends PluginSettingTab {
dropdown.selectEl.id = 'pdf-plus-default-color-dropdown';
})
}
this.addToggleSetting('colorPaletteInToolbar')
this.addToggleSetting('colorPaletteInToolbar', () => {
this.redisplay();
this.plugin.loadStyle();
})
.setName('Show color palette in the toolbar')
.setDesc('A color palette will be added to the toolbar of the PDF viewer. Clicking a color while selecting a range of text will copy a link to the selection with "&color=..." appended.');
this.addDropdowenSetting('defaultColorPaletteAction', COLOR_PALETTE_ACTIONS)
.setName('Default action when clicking on a color palette item')
.setDesc('You can change it for each viewer with the dropdown menu in the color palette.')
if (this.plugin.settings.colorPaletteInToolbar) {
this.addToggleSetting('colorPaletteInEmbedToolbar', () => this.plugin.loadStyle())
.setName('Show color palette for PDF embeds as well');
this.addDropdowenSetting('defaultColorPaletteAction', COLOR_PALETTE_ACTIONS)
.setName('Default action when clicking on a color palette item')
.setDesc('You can change it for each viewer with the dropdown menu in the color palette.')
}

this.addHeading('Opening links to PDF files');
this.addToggleSetting('openLinkCleverly', () => this.redisplay())
Expand Down

0 comments on commit ae0dcfe

Please sign in to comment.