mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 15:24: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 { dayjs, formatLogMessage } from "@triliumnext/commons";
|
||||||
import { Fragment, h, VNode } from "preact";
|
import { VNode } from "preact";
|
||||||
|
|
||||||
import appContext from "../components/app_context.js";
|
import appContext from "../components/app_context.js";
|
||||||
import type Component from "../components/component.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 dateNotesService from "./date_notes.js";
|
||||||
import dialogService from "./dialog.js";
|
import dialogService from "./dialog.js";
|
||||||
import froca from "./froca.js";
|
import froca from "./froca.js";
|
||||||
|
import { preactAPI } from "./frontend_script_api_preact.js";
|
||||||
import { t } from "./i18n.js";
|
import { t } from "./i18n.js";
|
||||||
import linkService from "./link.js";
|
import linkService from "./link.js";
|
||||||
import noteTooltipService from "./note_tooltip.js";
|
import noteTooltipService from "./note_tooltip.js";
|
||||||
@ -475,8 +476,7 @@ export interface Api {
|
|||||||
*/
|
*/
|
||||||
defineWidget(definition: WidgetDefinition): void;
|
defineWidget(definition: WidgetDefinition): void;
|
||||||
|
|
||||||
h: typeof h;
|
preact: typeof preactAPI;
|
||||||
Fragment: typeof Fragment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WidgetDefinition {
|
export interface WidgetDefinition {
|
||||||
@ -751,8 +751,7 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
|
|||||||
...definition
|
...definition
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
this.h = h;
|
this.preact = preactAPI;
|
||||||
this.Fragment = Fragment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FrontendScriptApi as any as {
|
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;
|
const content = Buffer.isBuffer(contentRaw) ? contentRaw.toString("utf-8") : contentRaw;
|
||||||
return transform(content, {
|
return transform(content, {
|
||||||
transforms: ["jsx"],
|
transforms: ["jsx"],
|
||||||
jsxPragma: "api.h",
|
jsxPragma: "api.preact.h",
|
||||||
jsxFragmentPragma: "api.Fragment",
|
jsxFragmentPragma: "api.preact.Fragment",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user