mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-28 17:11:30 +00:00
Preparing v0.24.0
This commit is contained in:
55
src/modules/AbstractObsidianModule.ts
Normal file
55
src/modules/AbstractObsidianModule.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { type Prettify } from "../lib/src/common/types";
|
||||
import type { LiveSyncCore } from "../main";
|
||||
import type ObsidianLiveSyncPlugin from "../main";
|
||||
import { AbstractModule } from "./AbstractModule.ts";
|
||||
import type { ChainableExecuteFunction, OverridableFunctionsKeys } from "./ModuleTypes";
|
||||
|
||||
|
||||
export type IObsidianModuleBase = OverridableFunctionsKeys<ObsidianLiveSyncPlugin>;
|
||||
export type IObsidianModule = Prettify<Partial<IObsidianModuleBase>>
|
||||
export type ModuleKeys = keyof IObsidianModule;
|
||||
export type ChainableModuleProps = ChainableExecuteFunction<ObsidianLiveSyncPlugin>;
|
||||
|
||||
|
||||
export abstract class AbstractObsidianModule extends AbstractModule {
|
||||
|
||||
addCommand = this.plugin.addCommand.bind(this.plugin);
|
||||
registerView = this.plugin.registerView.bind(this.plugin);
|
||||
addRibbonIcon = this.plugin.addRibbonIcon.bind(this.plugin);
|
||||
registerObsidianProtocolHandler = this.plugin.registerObsidianProtocolHandler.bind(this.plugin);
|
||||
|
||||
get localDatabase() {
|
||||
return this.plugin.localDatabase;
|
||||
}
|
||||
get settings() {
|
||||
return this.plugin.settings;
|
||||
}
|
||||
set settings(value) {
|
||||
this.plugin.settings = value;
|
||||
}
|
||||
get app() {
|
||||
return this.plugin.app;
|
||||
}
|
||||
|
||||
constructor(public plugin: ObsidianLiveSyncPlugin, public core: LiveSyncCore) {
|
||||
super(core);
|
||||
}
|
||||
|
||||
saveSettings = this.plugin.saveSettings.bind(this.plugin);
|
||||
|
||||
|
||||
$isMainReady() {
|
||||
return this.core.$isMainReady();
|
||||
}
|
||||
$isMainSuspended() {
|
||||
return this.core.$isMainSuspended();
|
||||
}
|
||||
$isDatabaseReady() {
|
||||
return this.core.$isDatabaseReady();
|
||||
}
|
||||
|
||||
//should be overridden
|
||||
$isThisModuleEnabled() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user