mirror of https://github.com/laurent22/joplin.git
Plugins: Adds `joplin.workspace.onResourceChange`
parent
59cdcaf8d1
commit
2660ff3af6
|
@ -63,6 +63,7 @@ import ShareService from '@joplin/lib/services/share/ShareService';
|
||||||
import checkForUpdates from './checkForUpdates';
|
import checkForUpdates from './checkForUpdates';
|
||||||
import { AppState } from './app.reducer';
|
import { AppState } from './app.reducer';
|
||||||
import syncDebugLog from '@joplin/lib/services/synchronizer/syncDebugLog';
|
import syncDebugLog from '@joplin/lib/services/synchronizer/syncDebugLog';
|
||||||
|
import eventManager from '../lib/eventManager';
|
||||||
// import { runIntegrationTests } from '@joplin/lib/services/e2ee/ppkTestUtils';
|
// import { runIntegrationTests } from '@joplin/lib/services/e2ee/ppkTestUtils';
|
||||||
|
|
||||||
const pluginClasses = [
|
const pluginClasses = [
|
||||||
|
@ -234,7 +235,7 @@ class Application extends BaseApplication {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadCustomCss(filePath: string) {
|
public async loadCustomCss(filePath: string) {
|
||||||
let cssString = '';
|
let cssString = '';
|
||||||
if (await fs.pathExists(filePath)) {
|
if (await fs.pathExists(filePath)) {
|
||||||
try {
|
try {
|
||||||
|
@ -523,6 +524,12 @@ class Application extends BaseApplication {
|
||||||
|
|
||||||
ResourceEditWatcher.instance().initialize(reg.logger(), (action: any) => { this.store().dispatch(action); }, (path: string) => bridge().openItem(path));
|
ResourceEditWatcher.instance().initialize(reg.logger(), (action: any) => { this.store().dispatch(action); }, (path: string) => bridge().openItem(path));
|
||||||
|
|
||||||
|
// Forwards the local event to the global event manager, so that it can
|
||||||
|
// be picked up by the plugin manager.
|
||||||
|
ResourceEditWatcher.instance().on('resourceChange', (event: any) => {
|
||||||
|
eventManager.emit('resourceChange', event);
|
||||||
|
});
|
||||||
|
|
||||||
RevisionService.instance().runInBackground();
|
RevisionService.instance().runInBackground();
|
||||||
|
|
||||||
// Make it available to the console window - useful to call revisionService.collectRevisions()
|
// Make it available to the console window - useful to call revisionService.collectRevisions()
|
||||||
|
|
|
@ -38,8 +38,13 @@ interface SyncStartEvent {
|
||||||
withErrors: boolean;
|
withErrors: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ResourceChangeEvent {
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
|
||||||
type ItemChangeHandler = (event: ItemChangeEvent)=> void;
|
type ItemChangeHandler = (event: ItemChangeEvent)=> void;
|
||||||
type SyncStartHandler = (event: SyncStartEvent)=> void;
|
type SyncStartHandler = (event: SyncStartEvent)=> void;
|
||||||
|
type ResourceChangeHandler = (event: ResourceChangeEvent)=> void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The workspace service provides access to all the parts of Joplin that
|
* The workspace service provides access to all the parts of Joplin that
|
||||||
|
@ -54,7 +59,7 @@ export default class JoplinWorkspace {
|
||||||
|
|
||||||
private store: any;
|
private store: any;
|
||||||
|
|
||||||
constructor(store: any) {
|
public constructor(store: any) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +103,14 @@ export default class JoplinWorkspace {
|
||||||
return makeListener(eventManager, 'itemChange', wrapperHandler);
|
return makeListener(eventManager, 'itemChange', wrapperHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a resource is changed. Currently this handled will not be
|
||||||
|
* called when a resource is added or deleted.
|
||||||
|
*/
|
||||||
|
public async onResourceChange(handler: ResourceChangeHandler): Promise<void> {
|
||||||
|
makeListener(eventManager, 'resourceChange', handler);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an alarm associated with a to-do is triggered.
|
* Called when an alarm associated with a to-do is triggered.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue