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,5 +1,4 @@
|
||||
import { dayjs, formatLogMessage } from "@triliumnext/commons";
|
||||
import { VNode } from "preact";
|
||||
|
||||
import appContext from "../components/app_context.js";
|
||||
import type Component from "../components/component.js";
|
||||
@@ -467,27 +466,9 @@ export interface Api {
|
||||
*/
|
||||
log(message: string | object): void;
|
||||
|
||||
|
||||
// Preact support
|
||||
/**
|
||||
* 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): void;
|
||||
|
||||
preact: typeof preactAPI;
|
||||
}
|
||||
|
||||
export interface WidgetDefinition {
|
||||
parent: "right-pane",
|
||||
render: () => VNode
|
||||
}
|
||||
|
||||
export interface WidgetDefinitionWithType extends WidgetDefinition {
|
||||
type: "react-widget"
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>This is the main frontend API interface for scripts. All the properties and methods are published in the "api" object
|
||||
* available in the JS frontend notes. You can use e.g. <code>api.showMessage(api.startNote.title);</code></p>
|
||||
@@ -744,13 +725,6 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
|
||||
this.logSpacedUpdates[noteId].scheduleUpdate();
|
||||
};
|
||||
|
||||
// React support.
|
||||
this.defineWidget = (definition) => {
|
||||
return {
|
||||
type: "react-widget",
|
||||
...definition
|
||||
};
|
||||
};
|
||||
this.preact = preactAPI;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user