-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: editor settings with prompt select generate system role
- Loading branch information
Showing
7 changed files
with
71 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Setting, SettingTab, setIcon } from "obsidian"; | ||
import BMOGPT, { DEFAULT_SETTINGS } from "src/main"; | ||
import { addDescriptionLink } from "src/utils/DescriptionLink"; | ||
|
||
|
||
export async function addEditorSettings(containerEl: HTMLElement, plugin: BMOGPT, SettingTab: SettingTab) { | ||
const toggleSettingContainer = containerEl.createDiv({ cls: 'toggleSettingContainer' }); | ||
toggleSettingContainer.createEl('h2', {text: 'Editor'}); | ||
|
||
const initialState = plugin.settings.toggleEditorSettings; | ||
const chevronIcon = toggleSettingContainer.createEl('span', { cls: 'chevron-icon' }); | ||
setIcon(chevronIcon, initialState ? 'chevron-down' : 'chevron-right'); | ||
|
||
// Create the settings container to be toggled | ||
const settingsContainer = containerEl.createDiv({ cls: 'settingsContainer' }); | ||
settingsContainer.style.display = initialState ? 'block' : 'none'; | ||
|
||
// Toggle visibility | ||
toggleSettingContainer.addEventListener('click', async () => { | ||
const isOpen = settingsContainer.style.display !== 'none'; | ||
if (isOpen) { | ||
setIcon(chevronIcon, 'chevron-right'); // Close state | ||
settingsContainer.style.display = 'none'; | ||
plugin.settings.toggleEditorSettings = false; | ||
|
||
} else { | ||
setIcon(chevronIcon, 'chevron-down'); // Open state | ||
settingsContainer.style.display = 'block'; | ||
plugin.settings.toggleEditorSettings = true; | ||
} | ||
await plugin.saveSettings(); | ||
}); | ||
|
||
new Setting(settingsContainer) | ||
.setName('Prompt Select Generate System') | ||
.setDesc(addDescriptionLink('System role for Prompt Select Generate.', 'https://github.com/longy2k/obsidian-bmo-chatbot/wiki/Prompt---Select---Generate-Command', '', '[Instructions]')) | ||
.addTextArea(text => text | ||
.setPlaceholder('You are a helpful assistant.') | ||
.setValue(plugin.settings.system_role_prompt_select_generate !== undefined ? plugin.settings.system_role_prompt_select_generate : DEFAULT_SETTINGS.system_role_prompt_select_generate) | ||
.onChange(async (value) => { | ||
plugin.settings.system_role_prompt_select_generate = value !== undefined ? value : DEFAULT_SETTINGS.system_role_prompt_select_generate; | ||
await plugin.saveSettings(); | ||
}) | ||
); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters