Add obsidian context

This commit is contained in:
Idrees Hassan
2025-11-03 21:51:56 -05:00
parent e50c2c8a1f
commit 2826077d7a
10 changed files with 189 additions and 14 deletions

View File

@@ -174,8 +174,43 @@ class BrowserExtensionContext extends Context {
}
}
class ObsidianContext extends Context {
/**
* @override
* @returns {boolean}
*/
isContextActive() {
// @ts-expect-error
return typeof app !== "undefined" && typeof app.vault !== "undefined";
}
/**
* @override
* @returns {Promise<BirbSaveData|{}>}
*/
async getSaveData() {
log("Loading save data from Obsidian plugin storage unimplemented");
return {};
}
/**
* @override
* @param {BirbSaveData} saveData
*/
async putSaveData(saveData) {
log("Saving data to Obsidian plugin storage unimplemented");
}
/** @override */
resetSaveData() {
log("Resetting save data in Obsidian plugin storage unimplemented");
}
}
const CONTEXTS = [
new UserScriptContext(),
new ObsidianContext(),
new BrowserExtensionContext(),
new LocalContext()
];
@@ -187,5 +222,5 @@ export function getContext() {
}
}
error("No applicable context found, defaulting to LocalContext");
return CONTEXTS[0];
return new LocalContext();
}