Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : Show/Hide delete button #29

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/components/Card.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@
<span use:folderIcon></span>{file.parent.path}
</div>
{/if}
<button
class="clickable-icon"
use:trashIcon
onclick={trashFile}
aria-label="Delete file"
></button>
{#if $settings.showDeleteButton}
<button
class="clickable-icon"
use:trashIcon
on:click|stopPropagation={trashFile}
/>
{/if}
</div>
</div>

Expand Down
16 changes: 16 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ export enum TitleDisplayMode {
export interface CardsViewSettings {
minCardWidth: number;
launchOnStart: boolean;
showDeleteButton: boolean;
displayTitle: TitleDisplayMode;
pinnedFiles: string[];
}

export const DEFAULT_SETTINGS: CardsViewSettings = {
minCardWidth: 200,
launchOnStart: false,
showDeleteButton: true,
displayTitle: TitleDisplayMode.Both,
pinnedFiles: [],
};
Expand Down Expand Up @@ -68,6 +70,20 @@ export class CardsViewSettingsTab extends PluginSettingTab {
}),
);

new Setting(containerEl)
.setName("Show delete button")
.setDesc(
"Disable this option to remove the delete button, so you dont delete any note accidentally.",
)
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.showDeleteButton)
.onChange(async (value) => {
this.plugin.settings.showDeleteButton = value;
await this.plugin.saveSettings();
}),
);

new Setting(containerEl)
.setName("Launch on start")
.setDesc("Open the cards view when Obsidian starts")
Expand Down