mirror of
https://github.com/Ellpeck/ObsidianCustomFrames.git
synced 2024-11-24 02:08:34 +01:00
added the option to add a ribbon icon
This commit is contained in:
parent
c0aaf17d17
commit
5d3254e7bb
5 changed files with 32 additions and 7 deletions
|
@ -50,11 +50,11 @@ If you create a frame that you think other people would like, don't hesitate to
|
||||||
## 🛣️ Roadmap
|
## 🛣️ Roadmap
|
||||||
- ~~Allow setting a custom icon for each pane~~
|
- ~~Allow setting a custom icon for each pane~~
|
||||||
- ~~Allow displaying custom frames in Markdown code blocks~~
|
- ~~Allow displaying custom frames in Markdown code blocks~~
|
||||||
|
- ~~Add the ability to add a ribbon button for a frame that opens it in the main view~~
|
||||||
- Allow creating links that open in a custom frame rather than the browser
|
- Allow creating links that open in a custom frame rather than the browser
|
||||||
- Possibly allow executing custom JavaScript in iframes (though security implications still need to be explored)
|
- Possibly allow executing custom JavaScript in iframes (though security implications still need to be explored)
|
||||||
- Add a global setting that causes popups to be opened in a new Obsidian window rather than the default browser
|
- Add a global setting that causes popups to be opened in a new Obsidian window rather than the default browser
|
||||||
- Add more options to Markdown mode, like allowing for back and forward buttons
|
- Add more options to Markdown mode, like allowing for back and forward buttons
|
||||||
- Add the ability to add a ribbon button for a frame that opens it in the main view
|
|
||||||
|
|
||||||
## ⚠️ Known Issues
|
## ⚠️ Known Issues
|
||||||
There are a few known issues with Custom Frames. If you encounter any of these, please **don't** report it on the issue tracker.
|
There are a few known issues with Custom Frames. If you encounter any of these, please **don't** report it on the issue tracker.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Plugin, Platform } from "obsidian";
|
import { Plugin, Platform } from "obsidian";
|
||||||
import { CustomFrame } from "./frame";
|
import { CustomFrame } from "./frame";
|
||||||
import { CustomFramesSettings, defaultSettings } from "./settings";
|
import { CustomFramesSettings, defaultSettings, getIcon } from "./settings";
|
||||||
import { CustomFramesSettingTab } from "./settings-tab";
|
import { CustomFramesSettingTab } from "./settings-tab";
|
||||||
import { CustomFrameView } from "./view";
|
import { CustomFrameView } from "./view";
|
||||||
|
|
||||||
|
@ -28,6 +28,9 @@ export default class CustomFramesPlugin extends Plugin {
|
||||||
name: `Open ${frame.displayName}`,
|
name: `Open ${frame.displayName}`,
|
||||||
callback: () => this.openLeaf(name),
|
callback: () => this.openLeaf(name),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (frame.addRibbonIcon)
|
||||||
|
this.addRibbonIcon(getIcon(frame), `Open ${frame.displayName}`, () => this.openLeaf(name));
|
||||||
} catch {
|
} catch {
|
||||||
console.error(`Couldn't register frame ${name}, is there already one with the same name?`);
|
console.error(`Couldn't register frame ${name}, is there already one with the same name?`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,16 @@ export class CustomFramesSettingTab extends PluginSettingTab {
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
new Setting(content)
|
||||||
|
.setName("Add Ribbon Icon")
|
||||||
|
.setDesc("Whether a button to open this frame should be added to the ribbon.")
|
||||||
|
.addToggle(t => {
|
||||||
|
t.setValue(frame.addRibbonIcon);
|
||||||
|
t.onChange(async v => {
|
||||||
|
frame.addRibbonIcon = v;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
});
|
||||||
|
});
|
||||||
new Setting(content)
|
new Setting(content)
|
||||||
.setName("Page Zoom")
|
.setName("Page Zoom")
|
||||||
.setDesc("The zoom that this frame's page should be displayed with, as a percentage.")
|
.setDesc("The zoom that this frame's page should be displayed with, as a percentage.")
|
||||||
|
@ -147,9 +157,10 @@ export class CustomFramesSettingTab extends PluginSettingTab {
|
||||||
url: "",
|
url: "",
|
||||||
displayName: "New Frame",
|
displayName: "New Frame",
|
||||||
icon: "",
|
icon: "",
|
||||||
|
hideOnMobile: true,
|
||||||
|
addRibbonIcon: false,
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
customCss: "",
|
customCss: ""
|
||||||
hideOnMobile: true
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -8,6 +8,7 @@ export const presets: Record<string, CustomFrameSettings> = {
|
||||||
displayName: "Obsidian Forum",
|
displayName: "Obsidian Forum",
|
||||||
icon: "edit",
|
icon: "edit",
|
||||||
hideOnMobile: true,
|
hideOnMobile: true,
|
||||||
|
addRibbonIcon: true,
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
customCss: ""
|
customCss: ""
|
||||||
},
|
},
|
||||||
|
@ -16,6 +17,7 @@ export const presets: Record<string, CustomFrameSettings> = {
|
||||||
displayName: "Google Calendar",
|
displayName: "Google Calendar",
|
||||||
icon: "calendar",
|
icon: "calendar",
|
||||||
hideOnMobile: true,
|
hideOnMobile: true,
|
||||||
|
addRibbonIcon: true,
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
customCss: `/* hide right-side menu, and some buttons */
|
customCss: `/* hide right-side menu, and some buttons */
|
||||||
div.d6McF,
|
div.d6McF,
|
||||||
|
@ -33,6 +35,7 @@ div.dwlvNd {
|
||||||
displayName: "Google Keep",
|
displayName: "Google Keep",
|
||||||
icon: "files",
|
icon: "files",
|
||||||
hideOnMobile: true,
|
hideOnMobile: true,
|
||||||
|
addRibbonIcon: false,
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
customCss: `/* hide the menu bar and the "Keep" text */
|
customCss: `/* hide the menu bar and the "Keep" text */
|
||||||
html > body > div:nth-child(2) > div:nth-child(2) > div:first-child,
|
html > body > div:nth-child(2) > div:nth-child(2) > div:first-child,
|
||||||
|
@ -45,6 +48,7 @@ html > body > div:first-child > header:first-child > div > div:first-child > div
|
||||||
displayName: "Todoist",
|
displayName: "Todoist",
|
||||||
icon: "list-checks",
|
icon: "list-checks",
|
||||||
hideOnMobile: true,
|
hideOnMobile: true,
|
||||||
|
addRibbonIcon: false,
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
customCss: `/* hide the help, home, search, and productivity overview buttons, create extra space, and prevent toast pop-up from acting weird */
|
customCss: `/* hide the help, home, search, and productivity overview buttons, create extra space, and prevent toast pop-up from acting weird */
|
||||||
[aria-label="Go to Home view"], #quick_find, [aria-label="Productivity"], [aria-label="Help & Feedback"] {
|
[aria-label="Go to Home view"], #quick_find, [aria-label="Productivity"], [aria-label="Help & Feedback"] {
|
||||||
|
@ -69,6 +73,7 @@ html > body > div:first-child > header:first-child > div > div:first-child > div
|
||||||
displayName: "Notion",
|
displayName: "Notion",
|
||||||
icon: "box",
|
icon: "box",
|
||||||
hideOnMobile: true,
|
hideOnMobile: true,
|
||||||
|
addRibbonIcon: true,
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
customCss: ""
|
customCss: ""
|
||||||
},
|
},
|
||||||
|
@ -77,6 +82,7 @@ html > body > div:first-child > header:first-child > div > div:first-child > div
|
||||||
displayName: "Twitter",
|
displayName: "Twitter",
|
||||||
icon: "twitter",
|
icon: "twitter",
|
||||||
hideOnMobile: true,
|
hideOnMobile: true,
|
||||||
|
addRibbonIcon: false,
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
customCss: ""
|
customCss: ""
|
||||||
}
|
}
|
||||||
|
@ -92,6 +98,11 @@ export interface CustomFrameSettings {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
hideOnMobile: boolean;
|
hideOnMobile: boolean;
|
||||||
|
addRibbonIcon: boolean;
|
||||||
zoomLevel: number;
|
zoomLevel: number;
|
||||||
customCss: string;
|
customCss: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getIcon(settings: CustomFrameSettings) {
|
||||||
|
return settings.icon ? `lucide-${settings.icon}` : "documents";
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import { ItemView, WorkspaceLeaf, Platform, Menu } from "obsidian";
|
import { ItemView, WorkspaceLeaf, Menu } from "obsidian";
|
||||||
import { CustomFrame } from "./frame";
|
import { CustomFrame } from "./frame";
|
||||||
import { CustomFrameSettings, CustomFramesSettings } from "./settings";
|
import { CustomFrameSettings, CustomFramesSettings, getIcon } from "./settings";
|
||||||
|
|
||||||
export class CustomFrameView extends ItemView {
|
export class CustomFrameView extends ItemView {
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ export class CustomFrameView extends ItemView {
|
||||||
}
|
}
|
||||||
|
|
||||||
getIcon(): string {
|
getIcon(): string {
|
||||||
return this.data.icon ? `lucide-${this.data.icon}` : "documents";
|
return getIcon(this.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue