You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-13 00:10:37 +02:00
Windows: Fix PDF, video, and audio rendering (#10881)
This commit is contained in:
@ -6,7 +6,8 @@ import shim from '@joplin/lib/shim';
|
||||
|
||||
const { themeStyle } = require('@joplin/lib/theme');
|
||||
import Note from '@joplin/lib/models/Note';
|
||||
import { MarkupToHtmlOptions } from './types';
|
||||
import { MarkupToHtmlOptions, ResourceInfos } from './types';
|
||||
import { resourceFullPath } from '@joplin/lib/models/utils/resourceUtils';
|
||||
|
||||
interface HookDependencies {
|
||||
themeId: number;
|
||||
@ -20,12 +21,16 @@ interface HookDependencies {
|
||||
export default function useMarkupToHtml(deps: HookDependencies) {
|
||||
const { themeId, customCss, plugins, whiteBackgroundNoteRendering } = deps;
|
||||
|
||||
const resourceBaseUrl = useMemo(() => {
|
||||
return `joplin-content://note-viewer/${Setting.value('resourceDir')}/`;
|
||||
}, []);
|
||||
|
||||
const markupToHtml = useMemo(() => {
|
||||
return markupLanguageUtils.newMarkupToHtml(plugins, {
|
||||
resourceBaseUrl: `joplin-content://note-viewer/${Setting.value('resourceDir')}/`,
|
||||
resourceBaseUrl,
|
||||
customCss: customCss || '',
|
||||
});
|
||||
}, [plugins, customCss]);
|
||||
}, [plugins, customCss, resourceBaseUrl]);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||
return useCallback(async (markupLanguage: number, md: string, options: MarkupToHtmlOptions = null): Promise<any> => {
|
||||
@ -39,7 +44,7 @@ export default function useMarkupToHtml(deps: HookDependencies) {
|
||||
md = md || '';
|
||||
|
||||
const theme = themeStyle(themeId);
|
||||
let resources = {};
|
||||
let resources: ResourceInfos = {};
|
||||
|
||||
if (options.replaceResourceInternalToExternalLinks) {
|
||||
md = await Note.replaceResourceInternalToExternalLinks(md, { useAbsolutePaths: true });
|
||||
@ -58,9 +63,16 @@ export default function useMarkupToHtml(deps: HookDependencies) {
|
||||
codeHighlightCacheKey: 'useMarkupToHtml',
|
||||
settingValue: deps.settingValue,
|
||||
whiteBackgroundNoteRendering,
|
||||
itemIdToUrl: (id: string, urlParameters = '') => {
|
||||
if (!(id in resources) || !resources[id]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return resourceFullPath(resources[id].item, resourceBaseUrl) + urlParameters;
|
||||
},
|
||||
...options,
|
||||
});
|
||||
|
||||
return result;
|
||||
}, [themeId, markupToHtml, whiteBackgroundNoteRendering, deps.settingValue]);
|
||||
}, [themeId, markupToHtml, whiteBackgroundNoteRendering, resourceBaseUrl, deps.settingValue]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user