mirror of
https://github.com/zadam/trilium.git
synced 2025-12-23 00:29:59 +01:00
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { Fragment, h, VNode } from "preact";
|
|
import * as hooks from "preact/hooks";
|
|
|
|
import * as triliumHooks from "../widgets/react/hooks";
|
|
import RightPanelWidget from "../widgets/sidebar/RightPanelWidget";
|
|
|
|
export interface WidgetDefinition {
|
|
parent: "right-pane",
|
|
render: () => VNode,
|
|
position?: number,
|
|
}
|
|
|
|
export interface WidgetDefinitionWithType extends WidgetDefinition {
|
|
type: "preact-widget"
|
|
}
|
|
|
|
export interface LauncherWidgetDefinitionWithType {
|
|
type: "preact-launcher-widget"
|
|
render: () => VNode
|
|
}
|
|
|
|
export const preactAPI = Object.freeze({
|
|
// Core
|
|
h,
|
|
Fragment,
|
|
|
|
/**
|
|
* Method that must be run for widget scripts that run on Preact, using JSX. The method just returns the same definition, reserved for future typechecking and perhaps validation purposes.
|
|
*
|
|
* @param definition the widget definition.
|
|
*/
|
|
defineWidget(definition: WidgetDefinition) {
|
|
return {
|
|
type: "preact-widget",
|
|
...definition
|
|
};
|
|
},
|
|
|
|
defineLauncherWidget(definition: Omit<LauncherWidgetDefinitionWithType, "type">) {
|
|
return {
|
|
type: "preact-launcher-widget",
|
|
...definition
|
|
};
|
|
},
|
|
|
|
RightPanelWidget,
|
|
|
|
...hooks,
|
|
...triliumHooks
|
|
});
|