一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
59 行
1.6 KiB
TypeScript
59 行
1.6 KiB
TypeScript
import { Store } from 'redux';
|
|
import { ViewHandle } from './utils/createViewHandle';
|
|
|
|
export interface EmitMessageEvent {
|
|
message: unknown;
|
|
}
|
|
|
|
// State shape varies between desktop (AppState with mainLayout) and mobile; subclasses access fields not present on the base lib State.
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Store state is heterogeneous across desktop/mobile callers
|
|
export type PluginStore = Store<any>;
|
|
|
|
export default class ViewController {
|
|
|
|
private handle_: ViewHandle;
|
|
private pluginId_: string;
|
|
private store_: PluginStore;
|
|
|
|
public constructor(handle: ViewHandle, pluginId: string, store: PluginStore) {
|
|
this.handle_ = handle;
|
|
this.pluginId_ = pluginId;
|
|
this.store_ = store;
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- View shape varies by controller subtype (menu, panel, dialog, toolbar button); subclasses index into different fields
|
|
protected get storeView(): any {
|
|
return this.store_.getState().pluginService.plugins[this.pluginId_].views[this.handle];
|
|
}
|
|
|
|
protected get store(): PluginStore {
|
|
return this.store_;
|
|
}
|
|
|
|
public get pluginId(): string {
|
|
return this.pluginId_;
|
|
}
|
|
|
|
public get key(): string {
|
|
return this.handle_;
|
|
}
|
|
|
|
public get handle(): ViewHandle {
|
|
return this.handle_;
|
|
}
|
|
|
|
public get type(): string {
|
|
throw new Error('Must be overriden');
|
|
}
|
|
|
|
public async emitMessage(event: EmitMessageEvent): Promise<unknown> {
|
|
console.warn('Calling ViewController.emitMessage - but not implemented', event);
|
|
return undefined;
|
|
}
|
|
|
|
public postMessage(message: unknown) {
|
|
console.warn('Calling ViewController.postMessage - but not implemented', message);
|
|
}
|
|
|
|
}
|