diff --git a/src/public/app/services/bundle.ts b/src/public/app/services/bundle.ts index e3ba2c21a..071d89458 100644 --- a/src/public/app/services/bundle.ts +++ b/src/public/app/services/bundle.ts @@ -7,8 +7,9 @@ import { t } from "./i18n.js"; import { Entity } from "./frontend_script_api.js"; // TODO: Deduplicate with server. -interface Bundle { +export interface Bundle { script: string; + html: string; noteId: string; allNoteIds: string[]; } diff --git a/src/public/app/services/library_loader.ts b/src/public/app/services/library_loader.ts index 84afb2077..a3e79e8c9 100644 --- a/src/public/app/services/library_loader.ts +++ b/src/public/app/services/library_loader.ts @@ -2,12 +2,11 @@ import mimeTypesService from "./mime_types.js"; import optionsService from "./options.js"; import { getStylesheetUrl } from "./syntax_highlight.js"; -interface Library { +export interface Library { js?: string[] | (() => string[]); css?: string[]; } - const CKEDITOR: Library = { js: ["libraries/ckeditor/ckeditor.js"] }; diff --git a/src/public/app/services/render.ts b/src/public/app/services/render.ts index 34e5fc901..9a998b573 100644 --- a/src/public/app/services/render.ts +++ b/src/public/app/services/render.ts @@ -1,11 +1,7 @@ import server from "./server.js"; -import bundleService from "./bundle.js"; +import bundleService, { Bundle } from "./bundle.js"; import FNote from "../entities/fnote.js"; -interface Bundle { - html: string; -} - async function render(note: FNote, $el: JQuery) { const relations = note.getRelations('renderNote'); const renderNoteIds = relations diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.ts index 6e2f57ccf..8a509b71c 100644 --- a/src/public/app/types.d.ts +++ b/src/public/app/types.d.ts @@ -6,6 +6,7 @@ import { Suggestion } from "./services/note_autocomplete.ts"; import utils from "./services/utils.ts"; import appContext from "./components/app_context.ts"; import server from "./services/server.ts"; +import library_loader, { Library } from "./services/library_loader.ts"; interface ElectronProcess { type: string; @@ -21,8 +22,8 @@ interface CustomGlobals { getReferenceLinkTitle: (href: string) => Promise; getReferenceLinkTitleSync: (href: string) => string; getActiveContextNote: FNote; - requireLibrary: (library: string) => Promise; - ESLINT: { js: string[]; }; + requireLibrary: typeof library_loader.requireLibrary; + ESLINT: Library; appContext: AppContext; froca: Froca; treeCache: Froca; @@ -70,7 +71,7 @@ declare global { displayKey: "name" | "value" | "notePathTitle"; cache: boolean; source: (term: string, cb: AutoCompleteCallback) => void, - templates: { + templates?: { suggestion: (suggestion: Suggestion) => string | undefined } };