2025-12-20 21:25:36 +02:00
|
|
|
import { Fragment, h, VNode } from "preact";
|
2025-12-20 20:29:03 +02:00
|
|
|
import * as hooks from "preact/hooks";
|
2025-12-20 20:10:19 +02:00
|
|
|
|
2025-12-20 23:26:10 +02:00
|
|
|
import * as triliumHooks from "../widgets/react/hooks";
|
2025-12-20 21:19:53 +02:00
|
|
|
import RightPanelWidget from "../widgets/sidebar/RightPanelWidget";
|
|
|
|
|
|
2025-12-20 21:25:36 +02:00
|
|
|
export interface WidgetDefinition {
|
|
|
|
|
parent: "right-pane",
|
2025-12-21 10:02:13 +02:00
|
|
|
render: () => VNode,
|
|
|
|
|
position?: number,
|
2025-12-20 21:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface WidgetDefinitionWithType extends WidgetDefinition {
|
2025-12-20 21:26:01 +02:00
|
|
|
type: "preact-widget"
|
2025-12-20 21:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
2025-12-20 20:10:19 +02:00
|
|
|
export const preactAPI = Object.freeze({
|
|
|
|
|
// Core
|
|
|
|
|
h,
|
2025-12-20 20:29:03 +02:00
|
|
|
Fragment,
|
|
|
|
|
|
2025-12-20 21:25:36 +02:00
|
|
|
/**
|
|
|
|
|
* 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 {
|
2025-12-20 21:26:01 +02:00
|
|
|
type: "preact-widget",
|
2025-12-20 21:25:36 +02:00
|
|
|
...definition
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
2025-12-20 21:19:53 +02:00
|
|
|
RightPanelWidget,
|
|
|
|
|
|
2025-12-20 23:26:10 +02:00
|
|
|
...hooks,
|
|
|
|
|
...triliumHooks
|
2025-12-20 20:10:19 +02:00
|
|
|
});
|