2024-01-18 13:20:10 +02:00
|
|
|
import { MarkupLanguage } from './MarkupToHtml';
|
|
|
|
import { Options as NoteStyleOptions } from './noteStyle';
|
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
export type ItemIdToUrlHandler = (resource: any)=> string;
|
|
|
|
|
|
|
|
interface ResourceEntity {
|
|
|
|
id: string;
|
|
|
|
title?: string;
|
|
|
|
mime?: string;
|
|
|
|
file_extension?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface FsDriver {
|
|
|
|
writeFile: (path: string, content: string, encoding: string)=> Promise<void>;
|
|
|
|
exists: (path: string)=> Promise<boolean>;
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
cacheCssToFile: (cssStrings: string[])=> Promise<any>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderOptions {
|
|
|
|
contentMaxWidth?: number;
|
|
|
|
bodyOnly?: boolean;
|
|
|
|
splitted?: boolean;
|
|
|
|
enableLongPress?: boolean;
|
|
|
|
postMessageSyntax?: string;
|
|
|
|
|
|
|
|
externalAssetsOnly?: boolean;
|
|
|
|
highlightedKeywords?: string[];
|
|
|
|
codeTheme?: string;
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
theme?: any;
|
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
plugins?: Record<string, any>;
|
|
|
|
audioPlayerEnabled?: boolean;
|
|
|
|
videoPlayerEnabled?: boolean;
|
|
|
|
pdfViewerEnabled?: boolean;
|
|
|
|
|
|
|
|
codeHighlightCacheKey?: string;
|
|
|
|
plainResourceRendering?: boolean;
|
|
|
|
|
|
|
|
mapsToLine?: boolean;
|
|
|
|
useCustomPdfViewer?: boolean;
|
|
|
|
noteId?: string;
|
|
|
|
vendorDir?: string;
|
|
|
|
itemIdToUrl?: ItemIdToUrlHandler;
|
|
|
|
allowedFilePrefixes?: string[];
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
settingValue?: (pluginId: string, key: string)=> any;
|
|
|
|
|
|
|
|
resources?: Record<string, ResourceEntity>;
|
|
|
|
|
|
|
|
// HtmlToHtml only
|
|
|
|
whiteBackgroundNoteRendering?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderResultPluginAsset {
|
|
|
|
name: string;
|
|
|
|
mime: string;
|
|
|
|
path: string;
|
|
|
|
|
|
|
|
// For built-in Mardown-it plugins, the asset path is relative (and can be
|
|
|
|
// found inside the @joplin/renderer package), while for external plugins
|
|
|
|
// (content scripts), the path is absolute. We use this property to tell if
|
|
|
|
// it's relative or absolute, as that will inform how it's loaded in various
|
|
|
|
// places.
|
|
|
|
pathIsAbsolute: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderResult {
|
|
|
|
html: string;
|
|
|
|
pluginAssets: RenderResultPluginAsset[];
|
|
|
|
cssStrings: string[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface MarkupRenderer {
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
render(markup: string, theme: any, options: RenderOptions): Promise<RenderResult>;
|
|
|
|
clearCache(): void;
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
allAssets(theme: any, noteStyleOptions: NoteStyleOptions|null): Promise<RenderResultPluginAsset[]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface StripMarkupOptions {
|
|
|
|
collapseWhiteSpaces: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface MarkupToHtmlConverter {
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
render(markupLanguage: MarkupLanguage, markup: string, theme: any, options: any): Promise<RenderResult>;
|
|
|
|
clearCache(markupLanguage: MarkupLanguage): void;
|
|
|
|
stripMarkup(markupLanguage: MarkupLanguage, markup: string, options: StripMarkupOptions): string;
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-01-18 13:20:10 +02:00
|
|
|
allAssets(markupLanguage: MarkupLanguage, theme: any, noteStyleOptions: NoteStyleOptions|null): Promise<RenderResultPluginAsset[]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface OptionsResourceModel {
|
|
|
|
isResourceUrl: (url: string)=> boolean;
|
|
|
|
urlToId: (url: string)=> string;
|
|
|
|
filename: (resource: ResourceEntity, encryptedBlob?: boolean)=> string;
|
|
|
|
isSupportedImageMimeType: (type: string)=> boolean;
|
|
|
|
fullPath?: (resource: ResourceEntity, encryptedBlob?: boolean)=> string;
|
|
|
|
}
|