diff --git a/apps/client/src/services/frontend_script_api.ts b/apps/client/src/services/frontend_script_api.ts index 46c59c4cd..e7e2cb84e 100644 --- a/apps/client/src/services/frontend_script_api.ts +++ b/apps/client/src/services/frontend_script_api.ts @@ -1,5 +1,5 @@ import { dayjs, formatLogMessage } from "@triliumnext/commons"; -import { Fragment, h, VNode } from "preact"; +import { VNode } from "preact"; import appContext from "../components/app_context.js"; import type Component from "../components/component.js"; @@ -11,6 +11,7 @@ import RightPanelWidget from "../widgets/right_panel_widget.js"; import dateNotesService from "./date_notes.js"; import dialogService from "./dialog.js"; import froca from "./froca.js"; +import { preactAPI } from "./frontend_script_api_preact.js"; import { t } from "./i18n.js"; import linkService from "./link.js"; import noteTooltipService from "./note_tooltip.js"; @@ -475,8 +476,7 @@ export interface Api { */ defineWidget(definition: WidgetDefinition): void; - h: typeof h; - Fragment: typeof Fragment; + preact: typeof preactAPI; } export interface WidgetDefinition { @@ -751,8 +751,7 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig ...definition }; }; - this.h = h; - this.Fragment = Fragment; + this.preact = preactAPI; } export default FrontendScriptApi as any as { diff --git a/apps/client/src/services/frontend_script_api_preact.ts b/apps/client/src/services/frontend_script_api_preact.ts new file mode 100644 index 000000000..d728c057f --- /dev/null +++ b/apps/client/src/services/frontend_script_api_preact.ts @@ -0,0 +1,7 @@ +import { Fragment, h } from "preact"; + +export const preactAPI = Object.freeze({ + // Core + h, + Fragment +}); diff --git a/apps/server/src/services/script.ts b/apps/server/src/services/script.ts index 98fbb3e43..5e0682fbe 100644 --- a/apps/server/src/services/script.ts +++ b/apps/server/src/services/script.ts @@ -224,8 +224,8 @@ function buildJsx(jsxNote: BNote) { const content = Buffer.isBuffer(contentRaw) ? contentRaw.toString("utf-8") : contentRaw; return transform(content, { transforms: ["jsx"], - jsxPragma: "api.h", - jsxFragmentPragma: "api.Fragment", + jsxPragma: "api.preact.h", + jsxFragmentPragma: "api.preact.Fragment", }); }