From 3c1db281c7244319ee68d9289e2a8a0865e4a7c9 Mon Sep 17 00:00:00 2001 From: latenitecoding Date: Sat, 27 Jan 2024 20:29:27 -0600 Subject: [PATCH] adds option to disable comments --- README.md | 1 + src/components/obsidian/SettingsTab.ts | 18 ++++++++++++++++++ src/components/react/ChessStudy.tsx | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) 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..f73849c 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 as true | false; + this.plugin.saveSettings(); + }); + }); + } } diff --git a/src/components/react/ChessStudy.tsx b/src/components/react/ChessStudy.tsx index fe9d246..29553ed 100644 --- a/src/components/react/ChessStudy.tsx +++ b/src/components/react/ChessStudy.tsx @@ -55,7 +55,7 @@ export const ChessStudy = ({ dataAdapter, }: AppProps) => { // Parse Obsidian / Code Block Settings - const { boardColor, boardOrientation, chessStudyId } = parseUserConfig( + const { boardColor, boardOrientation, viewComments, chessStudyId } = parseUserConfig( pluginSettings, source ); @@ -277,12 +277,14 @@ export const ChessStudy = ({
+ { viewComments && dispatch({ type: 'SYNC_COMMENT', comment: comment }) } /> + }
);