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
38e11cc131
3 changed files with 31 additions and 12 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 == true || viewComments == "true" || viewComments == "True") as true | false;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Api | null>(null);
|
||||
|
|
@ -276,14 +274,16 @@ export const ChessStudy = ({
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="CommentSection">
|
||||
<CommentSection
|
||||
currentComment={gameState.currentMove?.comment}
|
||||
setComments={(comment: JSONContent) =>
|
||||
dispatch({ type: 'SYNC_COMMENT', comment: comment })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{viewComments && (
|
||||
<div className="CommentSection">
|
||||
<CommentSection
|
||||
currentComment={gameState.currentMove?.comment}
|
||||
setComments={(comment: JSONContent) =>
|
||||
dispatch({ type: 'SYNC_COMMENT', comment: comment })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue