Skip to content

Commit

Permalink
feat(WriteBCToFile): ✨ Setting to show `Write Breadcrumbs to ALL File…
Browse files Browse the repository at this point in the history
…s` cmd. Off by default
  • Loading branch information
SkepticMystic committed Sep 9, 2021
1 parent b0b012b commit 7ff2d06
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
13 changes: 13 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24764,6 +24764,17 @@ class BreadcrumbsSettingTab extends obsidian.PluginSettingTab {
await plugin.saveSettings();
await plugin.drawTrail();
}));
const writeBCsToFileDetails = containerEl.createEl("details");
writeBCsToFileDetails.createEl("summary", { text: "Write Breadcrumbs to File" });
new obsidian.Setting(writeBCsToFileDetails)
.setName("Show the `Write Breadcrumbs to ALL Files` command")
.setDesc("This command attempts to update ALL files with implied breadcrumbs pointing to them. So, it is not even shown by default (even though it has 3 confirmation boxes to ensure you want to run it")
.addToggle((toggle) => toggle
.setValue(settings.showWriteAllBCsCmd)
.onChange(async (value) => {
settings.showWriteAllBCsCmd = value;
await plugin.saveSettings();
}));
const visModalDetails = containerEl.createEl("details");
visModalDetails.createEl("summary", { text: "Visualisation Modal" });
new obsidian.Setting(visModalDetails)
Expand Down Expand Up @@ -37102,6 +37113,7 @@ const DEFAULT_SETTINGS = {
noPathMessage: `This note has no real or implied parents`,
trailSeperator: "→",
respectReadableLineLength: true,
showWriteAllBCsCmd: false,
visGraph: "Force Directed Graph",
visRelation: "Parent",
visClosed: "Real",
Expand Down Expand Up @@ -37411,6 +37423,7 @@ class BreadcrumbsPlugin extends obsidian.Plugin {
}
}
},
checkCallback: () => this.settings.showWriteAllBCsCmd
});
this.addRibbonIcon("dice", "Breadcrumbs Visualisation", () => new VisModal(this.app, this).open());
this.addSettingTab(new BreadcrumbsSettingTab(this.app, this));
Expand Down
17 changes: 17 additions & 0 deletions src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,23 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
})
);

const writeBCsToFileDetails: HTMLDetailsElement = containerEl.createEl("details");
writeBCsToFileDetails.createEl("summary", { text: "Write Breadcrumbs to File" });

new Setting(writeBCsToFileDetails)
.setName("Show the `Write Breadcrumbs to ALL Files` command")
.setDesc(
"This command attempts to update ALL files with implied breadcrumbs pointing to them. So, it is not even shown by default (even though it has 3 confirmation boxes to ensure you want to run it"
)
.addToggle((toggle) =>
toggle
.setValue(settings.showWriteAllBCsCmd)
.onChange(async (value) => {
settings.showWriteAllBCsCmd = value;
await plugin.saveSettings();
})
);

const visModalDetails: HTMLDetailsElement = containerEl.createEl("details");
visModalDetails.createEl("summary", { text: "Visualisation Modal" });

Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface BreadcrumbsSettings {
noPathMessage: string;
trailSeperator: string;
respectReadableLineLength: boolean;
showWriteAllBCsCmd: boolean;
visGraph: visTypes;
visRelation: Relations;
visClosed: string;
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const DEFAULT_SETTINGS: BreadcrumbsSettings = {
noPathMessage: `This note has no real or implied parents`,
trailSeperator: "→",
respectReadableLineLength: true,
showWriteAllBCsCmd: false,
visGraph: "Force Directed Graph",
visRelation: "Parent",
visClosed: "Real",
Expand Down Expand Up @@ -328,7 +329,6 @@ export default class BreadcrumbsPlugin extends Plugin {
name: "Write Breadcrumbs to **ALL** Files",
callback: () => {
const first = window.confirm("This action will write the implied Breadcrumbs of each file to that file.\nIt uses the MetaEdit plugins API to update the YAML, so it should only affect that frontmatter of your note.\nI can't promise that nothing bad will happen. **This operation cannot be undone**.");

if (first) {
const second = window.confirm('Are you sure? You have been warned that this operation will attempt to update all files with implied breadcrumbs.');
if (second) {
Expand All @@ -347,6 +347,7 @@ export default class BreadcrumbsPlugin extends Plugin {
}

},
checkCallback: () => this.settings.showWriteAllBCsCmd
});

this.addRibbonIcon("dice", "Breadcrumbs Visualisation", () =>
Expand Down

0 comments on commit 7ff2d06

Please sign in to comment.