mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 16:20:08 +01:00
fix(script/jsx): cannot find preact hydration function
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { dayjs } from "@triliumnext/commons";
|
||||
import { formatLogMessage } from "@triliumnext/commons";
|
||||
import { VNode } from "preact";
|
||||
import { dayjs, formatLogMessage } from "@triliumnext/commons";
|
||||
import { Fragment, h, VNode } from "preact";
|
||||
|
||||
import appContext from "../components/app_context.js";
|
||||
import type Component from "../components/component.js";
|
||||
@@ -467,12 +466,17 @@ 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;
|
||||
|
||||
h: typeof h;
|
||||
Fragment: typeof Fragment;
|
||||
}
|
||||
|
||||
export interface WidgetDefinition {
|
||||
@@ -739,12 +743,16 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
|
||||
this.logMessages[noteId].push(message);
|
||||
this.logSpacedUpdates[noteId].scheduleUpdate();
|
||||
};
|
||||
|
||||
// React support.
|
||||
this.defineWidget = (definition) => {
|
||||
return {
|
||||
type: "react-widget",
|
||||
...definition
|
||||
};
|
||||
};
|
||||
this.h = h;
|
||||
this.Fragment = Fragment;
|
||||
}
|
||||
|
||||
export default FrontendScriptApi as any as {
|
||||
|
||||
Reference in New Issue
Block a user