Skip to content

Commit

Permalink
Merge pull request #708 from coryjthompson/575-add-ribbon-icon
Browse files Browse the repository at this point in the history
Add Sidebar Ribbon Icon
  • Loading branch information
chhoumann authored Jul 4, 2024
2 parents fd73927 + 2fcdc1f commit 1158818
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ export default class QuickAdd extends Plugin {

log.register(new ConsoleErrorLogger()).register(new GuiLogger(this));

if (this.settings.enableRibbonIcon) {
this.addRibbonIcon("file-plus", "QuickAdd", () => {
ChoiceSuggester.Open(this, this.settings.choices);
});
}

this.addSettingTab(new QuickAddSettingsTab(this.app, this));

this.app.workspace.onLayoutReady(() =>
Expand Down
20 changes: 20 additions & 0 deletions src/quickAddSettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface QuickAddSettings {
* Users _can_ still use User Scripts to do so by executing arbitrary JavaScript, but that is not something the plugin controls.
*/
disableOnlineFeatures: boolean;
enableRibbonIcon: boolean;
ai: {
defaultModel: Model["name"] | "Ask me";
defaultSystemPrompt: string;
Expand All @@ -48,6 +49,7 @@ export const DEFAULT_SETTINGS: QuickAddSettings = {
announceUpdates: true,
version: "0.0.0",
disableOnlineFeatures: true,
enableRibbonIcon: false,
ai: {
defaultModel: "Ask me",
defaultSystemPrompt: `As an AI assistant within Obsidian, your primary goal is to help users manage their ideas and knowledge more effectively. Format your responses using Markdown syntax. Please use the [[Obsidian]] link format. You can write aliases for the links by writing [[Obsidian|the alias after the pipe symbol]]. To use mathematical notation, use LaTeX syntax. LaTeX syntax for larger equations should be on separate lines, surrounded with double dollar signs ($$). You can also inline math expressions by wrapping it in $ symbols. For example, use $$w_{ij}^{\text{new}}:=w_{ij}^{\text{current}}+\eta\cdot\delta_j\cdot x_{ij}$$ on a separate line, but you can write "($\eta$ = learning rate, $\delta_j$ = error term, $x_{ij}$ = input)" inline.`,
Expand Down Expand Up @@ -84,6 +86,7 @@ export class QuickAddSettingsTab extends PluginSettingTab {
this.addTemplateFolderPathSetting();
this.addAnnounceUpdatesSetting();
this.addDisableOnlineFeaturesSetting();
this.addEnableRibbonIconSetting();
}

addAnnounceUpdatesSetting() {
Expand Down Expand Up @@ -194,4 +197,21 @@ export class QuickAddSettingsTab extends PluginSettingTab {
})
);
}

private addEnableRibbonIconSetting() {
new Setting(this.containerEl)
.setName("Show icon in sidebar")
.setDesc("Add QuickAdd icon to the sidebar ribbon. Requires a reload.")
.addToggle((toggle) => {
toggle
.setValue(settingsStore.getState().enableRibbonIcon)
.onChange((value:boolean) => {
settingsStore.setState({
enableRibbonIcon: value,
});

this.display();
})
});
}
}

0 comments on commit 1158818

Please sign in to comment.