mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 01:06:00 +02:00
feat(react): basic handling of note context aware
This commit is contained in:
@@ -4,6 +4,7 @@ import froca from "../services/froca.js";
|
||||
import { t } from "../services/i18n.js";
|
||||
import toastService from "../services/toast.js";
|
||||
import { renderReactWidget } from "./react/react_utils.jsx";
|
||||
import { EventNames, EventData } from "../components/app_context.js";
|
||||
|
||||
export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedComponent<T> {
|
||||
protected attrs: Record<string, string>;
|
||||
@@ -276,9 +277,10 @@ export function wrapReactWidgets<T extends TypedComponent<any>>(components: (T |
|
||||
return wrappedResult;
|
||||
}
|
||||
|
||||
class ReactWrappedWidget extends BasicWidget {
|
||||
export class ReactWrappedWidget extends BasicWidget {
|
||||
|
||||
private el: VNode;
|
||||
listeners: Record<string, (data: any) => void> = {};
|
||||
|
||||
constructor(el: VNode) {
|
||||
super();
|
||||
@@ -289,4 +291,10 @@ class ReactWrappedWidget extends BasicWidget {
|
||||
this.$widget = renderReactWidget(this, this.el);
|
||||
}
|
||||
|
||||
handleEvent<T extends EventNames>(name: T, data: EventData<T>): Promise<unknown[] | unknown> | null | undefined {
|
||||
const listener = this.listeners[name];
|
||||
console.log("Handle ", name, listener);
|
||||
listener?.(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user