diff --git a/README.md b/README.md index 147af73..beb59c6 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ Here are the available settings for a `chessStudy` code block: | `chessStudyId` | Valid nanoid | Valid ID for a file stored in the plugin storage | | `boardOrientation` | `white` \| `black` | Orientation of the board | | `boardColor` | `green` \| `brown` | Color of the board | +| `viewComments` | `true` \| `false` | Whether to display the comments section | You can permanently set some settings in the [Obsidian](https://obsidian.md/) plugin settings for Obsidian Chess Study. diff --git a/src/components/obsidian/SettingsTab.ts b/src/components/obsidian/SettingsTab.ts index 4e1e4a8..5eb0c48 100644 --- a/src/components/obsidian/SettingsTab.ts +++ b/src/components/obsidian/SettingsTab.ts @@ -4,11 +4,13 @@ import ChessStudyPlugin from 'src/main'; export interface ChessStudyPluginSettings { boardOrientation: 'white' | 'black'; boardColor: 'green' | 'brown'; + viewComments: true | false; } export const DEFAULT_SETTINGS: ChessStudyPluginSettings = { boardOrientation: 'white', boardColor: 'green', + viewComments: true, }; export class SettingsTab extends PluginSettingTab { @@ -55,5 +57,21 @@ export class SettingsTab extends PluginSettingTab { this.plugin.saveSettings(); }); }); + + new Setting(containerEl) + .setName('View Comments') + .setDesc('Sets the default view of the comments') + .addDropdown((dropdown) => { + dropdown.addOption('true', 'True'); + dropdown.addOption('false', 'False'); + + dropdown + .setValue(this.plugin.settings.viewComments) + .onChange((viewComments) => { + this.plugin.settings.viewComments = (viewComments == true || viewComments == "true" || viewComments == "True") as true | false; + this.plugin.saveSettings(); + }); + }); + } } diff --git a/src/components/react/ChessStudy.tsx b/src/components/react/ChessStudy.tsx index fe9d246..db1b136 100644 --- a/src/components/react/ChessStudy.tsx +++ b/src/components/react/ChessStudy.tsx @@ -55,10 +55,8 @@ export const ChessStudy = ({ dataAdapter, }: AppProps) => { // Parse Obsidian / Code Block Settings - const { boardColor, boardOrientation, chessStudyId } = parseUserConfig( - pluginSettings, - source - ); + const { boardColor, boardOrientation, viewComments, chessStudyId } = + parseUserConfig(pluginSettings, source); // Setup Chessground API const [chessView, setChessView] = useState(null); @@ -276,14 +274,16 @@ export const ChessStudy = ({ /> -
- - dispatch({ type: 'SYNC_COMMENT', comment: comment }) - } - /> -
+ {viewComments && ( +
+ + dispatch({ type: 'SYNC_COMMENT', comment: comment }) + } + /> +
+ )} ); };