mirror of
https://github.com/idanlib/ObsidianFastForwardLinkPlugin.git
synced 2026-07-22 11:30:28 +00:00
adding new settings
This commit is contained in:
parent
9af90eca19
commit
4694e60268
2 changed files with 61 additions and 19 deletions
78
main.ts
78
main.ts
|
|
@ -36,8 +36,8 @@ export default class RedirectPlugin extends Plugin {
|
|||
await this.loadSettings();
|
||||
|
||||
this.app.workspace.on("active-leaf-change", (leaf) => {
|
||||
console.log(leaf);
|
||||
// this.test();
|
||||
console.log("active-leaf-change: ", leaf);
|
||||
this.test();
|
||||
});
|
||||
|
||||
// This adds a settings tab so the user can configure various aspects of the plugin
|
||||
|
|
@ -66,17 +66,19 @@ export default class RedirectPlugin extends Plugin {
|
|||
.match(linkTextRegex)
|
||||
?.at(1);
|
||||
|
||||
console.log("redirectTargetText: ", targetNoteName);
|
||||
console.log("redirectTargetNote: ", targetNoteName);
|
||||
|
||||
if (targetNoteName) {
|
||||
const targetNotePath = this.app.metadataCache.getFirstLinkpathDest(
|
||||
getLinkpath(targetNoteName as string),
|
||||
getLinkpath(targetNoteName),
|
||||
""
|
||||
);
|
||||
console.log("targetNotePath: ", targetNotePath);
|
||||
this.app.workspace.openLinkText(
|
||||
targetNoteName || "",
|
||||
targetNotePath?.path as string
|
||||
// true,
|
||||
// { active: true }
|
||||
);
|
||||
} else {
|
||||
console.log("no redirect found");
|
||||
|
|
@ -97,21 +99,21 @@ export default class RedirectPlugin extends Plugin {
|
|||
await this.saveData(this.settings);
|
||||
}
|
||||
|
||||
getTargetFile(): TFile | null {
|
||||
// const currentFile = this.app.workspace.getActiveFile();
|
||||
const targetFile = this.app.vault.getFileByPath("_redirects/js.md");
|
||||
console.log(targetFile);
|
||||
// getTargetFile(): TFile | null {
|
||||
// // const currentFile = this.app.workspace.getActiveFile();
|
||||
// const targetFile = this.app.vault.getFileByPath("_redirects/js.md");
|
||||
// console.log(targetFile);
|
||||
|
||||
this.app.workspace.openLinkText(
|
||||
targetFile?.name as string,
|
||||
targetFile?.path as string,
|
||||
false,
|
||||
{
|
||||
active: false,
|
||||
}
|
||||
);
|
||||
return targetFile;
|
||||
}
|
||||
// this.app.workspace.openLinkText(
|
||||
// targetFile?.name as string,
|
||||
// targetFile?.path as string,
|
||||
// false,
|
||||
// {
|
||||
// active: false,
|
||||
// }
|
||||
// );
|
||||
// return targetFile;
|
||||
// }
|
||||
}
|
||||
|
||||
class RedirectSettingsTab extends PluginSettingTab {
|
||||
|
|
@ -142,5 +144,45 @@ class RedirectSettingsTab extends PluginSettingTab {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Open target note in new tab.")
|
||||
.setDesc("Whether to open the target note in a new tab.")
|
||||
.addToggle((toggle) => {
|
||||
toggle.setValue(true);
|
||||
// toggle.setTooltip("");
|
||||
toggle.onChange((value) => {
|
||||
console.log(value);
|
||||
if (value) {
|
||||
console.log("Yes, open target note in new tab.");
|
||||
// show the next setting: a toggle whether to automatically change view to the new tab
|
||||
} else {
|
||||
console.log("No, open target note in same tab.");
|
||||
// hide the next setting: a toggle whether to automatically change view to the new tab. Also make sure to DISABLE THE DEPENDENT OPTION - whether to switch to the new tab
|
||||
}
|
||||
});
|
||||
});
|
||||
// .clear(); // Clears (ie removes) whatever the setting instance contains (in this case, the toggle switch)
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Switch view to new tab.")
|
||||
.setDesc(
|
||||
"When the target note opens in a new tab, whether to switch view to the new tab."
|
||||
)
|
||||
.addToggle((toggle) => {
|
||||
toggle.setValue(true);
|
||||
// toggle.setTooltip("");
|
||||
toggle.onChange((value) => {
|
||||
console.log(value);
|
||||
if (value) {
|
||||
console.log("Yes, switch to new tab.");
|
||||
// show the next setting: a toggle whether to automatically change view to the new tab
|
||||
} else {
|
||||
console.log("No, switch to new tab.");
|
||||
// hide the next setting: a toggle whether to automatically change view to the new tab
|
||||
}
|
||||
});
|
||||
});
|
||||
// .clear(); // Clears (ie removes) whatever the setting instance contains (in this case, the toggle switch)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"id": "synonyms-plugin",
|
||||
"name": "obsidian-synonyms-plugin",
|
||||
"name": "obsidian-redirect-plugin",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "This plugin allows you to redirect multiple references to a single note.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue