You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-27 23:28:38 +02:00
All: Add support for application plugins (#3257)
This commit is contained in:
59
ReactNativeClient/lib/services/plugins/Plugin.ts
Normal file
59
ReactNativeClient/lib/services/plugins/Plugin.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import { PluginManifest } from './utils/types';
|
||||
import ViewController from './ViewController';
|
||||
import shim from 'lib/shim';
|
||||
import { ViewHandle } from './utils/createViewHandle';
|
||||
|
||||
interface ViewControllers {
|
||||
[key:string]: ViewController
|
||||
}
|
||||
|
||||
export default class Plugin {
|
||||
|
||||
private id_:string;
|
||||
private baseDir_:string;
|
||||
private manifest_:PluginManifest;
|
||||
private scriptText_:string;
|
||||
private enabled_:boolean = true;
|
||||
// @ts-ignore Should be useful later on
|
||||
private logger_:any = null;
|
||||
private viewControllers_:ViewControllers = {};
|
||||
|
||||
constructor(id:string, baseDir:string, manifest:PluginManifest, scriptText:string, logger:any) {
|
||||
this.id_ = id;
|
||||
this.baseDir_ = shim.fsDriver().resolve(baseDir);
|
||||
this.manifest_ = manifest;
|
||||
this.scriptText_ = scriptText;
|
||||
this.logger_ = logger;
|
||||
}
|
||||
|
||||
public get id():string {
|
||||
return this.id_;
|
||||
}
|
||||
|
||||
public get enabled():boolean {
|
||||
return this.enabled_;
|
||||
}
|
||||
|
||||
public get manifest():PluginManifest {
|
||||
return this.manifest_;
|
||||
}
|
||||
|
||||
public get scriptText():string {
|
||||
return this.scriptText_;
|
||||
}
|
||||
|
||||
public get baseDir():string {
|
||||
return this.baseDir_;
|
||||
}
|
||||
|
||||
public addViewController(v:ViewController) {
|
||||
if (this.viewControllers_[v.handle]) throw new Error(`View already added: ${v.handle}`);
|
||||
this.viewControllers_[v.handle] = v;
|
||||
}
|
||||
|
||||
public viewController(handle:ViewHandle):ViewController {
|
||||
if (!this.viewControllers_[handle]) throw new Error(`View not found: ${handle}`);
|
||||
return this.viewControllers_[handle];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user