update
This commit is contained in:
62
.obsidian/plugins/sync-graph-settings/main.js
vendored
Normal file
62
.obsidian/plugins/sync-graph-settings/main.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// main.ts
|
||||
var main_exports = {};
|
||||
__export(main_exports, {
|
||||
default: () => SyncGraphPlugin
|
||||
});
|
||||
module.exports = __toCommonJS(main_exports);
|
||||
var import_obsidian = require("obsidian");
|
||||
var SyncGraphPlugin = class extends import_obsidian.Plugin {
|
||||
async onload() {
|
||||
this.addCommand({
|
||||
id: "sync-graph-colorgroups-to-localgraph",
|
||||
name: "Sync Graph Settings to Local Graph",
|
||||
callback: async () => {
|
||||
await this.syncGlobalToLocal();
|
||||
}
|
||||
});
|
||||
}
|
||||
async syncGlobalToLocal() {
|
||||
const configDir = this.app.vault.configDir;
|
||||
const graphConfigPath = (0, import_obsidian.normalizePath)(configDir + "/graph.json");
|
||||
const graphConfigJson = await this.app.vault.adapter.read(graphConfigPath);
|
||||
const graphConfig = JSON.parse(graphConfigJson);
|
||||
const graphColorGroups = graphConfig.colorGroups;
|
||||
const searchFilters = graphConfig.search;
|
||||
this.getLocalGraphLeaves().forEach((leaf) => {
|
||||
this.setSettings(leaf, graphColorGroups, searchFilters);
|
||||
});
|
||||
}
|
||||
getLocalGraphLeaves() {
|
||||
return this.app.workspace.getLeavesOfType("localgraph");
|
||||
}
|
||||
setSettings(localGraphLeaf, colorGroups, searchFilters) {
|
||||
const viewState = localGraphLeaf.getViewState();
|
||||
viewState.state.options.colorGroups = colorGroups;
|
||||
viewState.state.options.search = searchFilters;
|
||||
localGraphLeaf.setViewState(viewState);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsibWFpbi50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiaW1wb3J0IHsgUGx1Z2luLCBXb3Jrc3BhY2VMZWFmLCBub3JtYWxpemVQYXRofSBmcm9tICdvYnNpZGlhbic7XG5cbmV4cG9ydCBkZWZhdWx0IGNsYXNzIFN5bmNHcmFwaFBsdWdpbiBleHRlbmRzIFBsdWdpbiB7XG5cdGFzeW5jIG9ubG9hZCgpIHtcblx0XHR0aGlzLmFkZENvbW1hbmQoe1xuXHRcdFx0aWQ6IFwic3luYy1ncmFwaC1jb2xvcmdyb3Vwcy10by1sb2NhbGdyYXBoXCIsXG5cdFx0XHRuYW1lOiBcIlN5bmMgR3JhcGggU2V0dGluZ3MgdG8gTG9jYWwgR3JhcGhcIixcblx0XHRcdGNhbGxiYWNrOiBhc3luYyAoKSA9PiB7IGF3YWl0IHRoaXMuc3luY0dsb2JhbFRvTG9jYWwoKSB9XG5cdFx0fSlcblx0fVxuXG5cdGFzeW5jIHN5bmNHbG9iYWxUb0xvY2FsKCkge1xuXHRcdGNvbnN0IGNvbmZpZ0RpciA9IHRoaXMuYXBwLnZhdWx0LmNvbmZpZ0Rpcjtcblx0XHRjb25zdCBncmFwaENvbmZpZ1BhdGggPSBub3Jt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