mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 07:14:24 +01:00
chore(script/jsx): move Preact API in dedicated object
This commit is contained in:
parent
644ff07a50
commit
4d7e5bc8f6
@ -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 {
|
||||
|
||||
7
apps/client/src/services/frontend_script_api_preact.ts
Normal file
7
apps/client/src/services/frontend_script_api_preact.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { Fragment, h } from "preact";
|
||||
|
||||
export const preactAPI = Object.freeze({
|
||||
// Core
|
||||
h,
|
||||
Fragment
|
||||
});
|
||||
@ -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",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user