mirror of
https://github.com/chrislicodes/obsidian-chess-study.git
synced 2026-07-22 07:50:30 +00:00
adds option to disable comments
This commit is contained in:
parent
f61649c0f1
commit
3c1db281c7
3 changed files with 22 additions and 1 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = ({
|
|||
</div>
|
||||
</div>
|
||||
<div className="CommentSection">
|
||||
{ viewComments &&
|
||||
<CommentSection
|
||||
currentComment={gameState.currentMove?.comment}
|
||||
setComments={(comment: JSONContent) =>
|
||||
dispatch({ type: 'SYNC_COMMENT', comment: comment })
|
||||
}
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue