mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 16:20:08 +01:00
chore(script/jsx): move defineWidget into Preact API
This commit is contained in:
@@ -1,13 +1,34 @@
|
||||
import { Fragment, h } from "preact";
|
||||
import { Fragment, h, VNode } from "preact";
|
||||
import * as hooks from "preact/hooks";
|
||||
|
||||
import RightPanelWidget from "../widgets/sidebar/RightPanelWidget";
|
||||
|
||||
export interface WidgetDefinition {
|
||||
parent: "right-pane",
|
||||
render: () => VNode
|
||||
}
|
||||
|
||||
export interface WidgetDefinitionWithType extends WidgetDefinition {
|
||||
type: "react-widget"
|
||||
}
|
||||
|
||||
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: "react-widget",
|
||||
...definition
|
||||
};
|
||||
},
|
||||
|
||||
RightPanelWidget,
|
||||
|
||||
...hooks
|
||||
|
||||
Reference in New Issue
Block a user