This commit is contained in:
Oscar Plaisant
2024-05-14 10:51:40 +02:00
parent f71d6b0503
commit 66c143b7b3
164 changed files with 25026 additions and 13829 deletions

View File

@@ -24,19 +24,67 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
// main.ts
var main_exports = {};
__export(main_exports, {
SyncGraphSettingTab: () => SyncGraphSettingTab,
default: () => SyncGraphPlugin
});
module.exports = __toCommonJS(main_exports);
var import_obsidian = require("obsidian");
var DEFAULT_SETTINGS = {
autoSync: false,
defaultDepth: 1,
defaultIncomingLinks: true,
defaultOutgoingLinks: true,
defaultNeighborLinks: true
};
var SyncGraphSettingTab = class extends import_obsidian.PluginSettingTab {
constructor(app, plugin) {
super(app, plugin);
this.plugin = plugin;
}
display() {
let { containerEl } = this;
containerEl.empty();
new import_obsidian.Setting(containerEl).setName("Auto Sync").addToggle((toggle) => toggle.setValue(this.plugin.settings.autoSync).onChange(async (value) => {
this.plugin.settings.autoSync = value;
await this.plugin.saveSettings();
}));
new import_obsidian.Setting(containerEl).setName("Default depth").addSlider((value) => value.setLimits(1, 10, 1).setValue(this.plugin.settings.defaultDepth).onChange(async (value2) => {
this.plugin.settings.defaultDepth = value2;
await this.plugin.saveSettings();
}).setDynamicTooltip());
new import_obsidian.Setting(containerEl).setName("Default Incoming Links").addToggle((toggle) => toggle.setValue(this.plugin.settings.defaultIncomingLinks).onChange(async (value) => {
this.plugin.settings.defaultIncomingLinks = value;
await this.plugin.saveSettings();
}));
new import_obsidian.Setting(containerEl).setName("Default Outgoing Links").addToggle((toggle) => toggle.setValue(this.plugin.settings.defaultOutgoingLinks).onChange(async (value) => {
this.plugin.settings.defaultOutgoingLinks = value;
await this.plugin.saveSettings();
}));
new import_obsidian.Setting(containerEl).setName("Default Neighbor Links").addToggle((toggle) => toggle.setValue(this.plugin.settings.defaultNeighborLinks).onChange(async (value) => {
this.plugin.settings.defaultNeighborLinks = value;
await this.plugin.saveSettings();
}));
}
};
var SyncGraphPlugin = class extends import_obsidian.Plugin {
async onload() {
await this.loadSettings();
this.addSettingTab(new SyncGraphSettingTab(this.app, this));
this.addCommand({
id: "sync-graph-colorgroups-to-localgraph",
id: "sync-graph-settings-to-localgraph",
name: "Sync Graph Settings to Local Graph",
callback: async () => {
await this.syncGlobalToLocal();
}
});
this.app.workspace.on("active-leaf-change", async () => {
if (this.settings.autoSync) {
await this.syncGlobalToLocal();
}
});
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
async syncGlobalToLocal() {
const configDir = this.app.vault.configDir;
@@ -56,7 +104,13 @@ var SyncGraphPlugin = class extends import_obsidian.Plugin {
const viewState = localGraphLeaf.getViewState();
viewState.state.options.colorGroups = colorGroups;
viewState.state.options.search = searchFilters;
viewState.state.options.localJumps = this.settings.defaultDepth;
viewState.state.options.localBacklinks = this.settings.defaultIncomingLinks;
viewState.state.options.localForelinks = this.settings.defaultOutgoingLinks;
viewState.state.options.localInterlinks = this.settings.defaultNeighborLinks;
localGraphLeaf.setViewState(viewState);
}
async saveSettings() {
await this.saveData(this.settings);
}
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsibWFpbi50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiaW1wb3J0IHsgUGx1Z2luLCBXb3Jrc3BhY2VMZWFmLCBub3JtYWxpemVQYXRofSBmcm9tICdvYnNpZGlhbic7XG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIFN5bmNHcmFwaFBsdWdpbiBleHRlbmRzIFBsdWdpbiB7XG5cdGFzeW5jIG9ubG9hZCgpIHtcblx0XHR0aGlzLmFkZENvbW1hbmQoe1xuXHRcdFx0aWQ6IFwic3luYy1ncmFwaC1jb2xvcmdyb3Vwcy10by1sb2NhbGdyYXBoXCIsXG5cdFx0XHRuYW1lOiBcIlN5bmMgR3JhcGggU2V0dGluZ3MgdG8gTG9jYWwgR3JhcGhcIixcblx0XHRcdGNhbGxiYWNrOi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