1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Mobile: Plugin API: Fix certain renderer plugins fail to load (#13078)

This commit is contained in:
Henry Heino
2025-08-29 14:28:39 -07:00
committed by GitHub
parent 859bc8d88e
commit ec74abe754

View File

@@ -185,7 +185,7 @@ const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
}; };
let settingsChanged = false; let settingsChanged = false;
const settings: RenderSettings = { const getSettings = (): RenderSettings => ({
...options, ...options,
codeTheme: theme.codeThemeCss, codeTheme: theme.codeThemeCss,
// We .stringify the theme to avoid a JSON serialization error involving // We .stringify the theme to avoid a JSON serialization error involving
@@ -220,12 +220,12 @@ const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
return shim.fsDriver().fileAtPath(resolvedPath); return shim.fsDriver().fileAtPath(resolvedPath);
}, },
removeUnusedPluginAssets: options.removeUnusedPluginAssets, removeUnusedPluginAssets: options.removeUnusedPluginAssets,
}; });
await transferResources(options.resources); await transferResources(options.resources);
return { return {
settings, getSettings,
getSettingsChanged() { getSettingsChanged() {
return settingsChanged; return settingsChanged;
}, },
@@ -234,23 +234,23 @@ const useWebViewSetup = (props: Props): SetUpResult<RendererControl> => {
return { return {
rerenderToBody: async (markup, options, cancelEvent) => { rerenderToBody: async (markup, options, cancelEvent) => {
const { settings, getSettingsChanged } = await prepareRenderer(options); const { getSettings, getSettingsChanged } = await prepareRenderer(options);
if (cancelEvent?.cancelled) return null; if (cancelEvent?.cancelled) return null;
const output = await renderer.rerenderToBody(markup, settings); const output = await renderer.rerenderToBody(markup, getSettings());
if (cancelEvent?.cancelled) return null; if (cancelEvent?.cancelled) return null;
if (getSettingsChanged()) { if (getSettingsChanged()) {
return await renderer.rerenderToBody(markup, settings); return await renderer.rerenderToBody(markup, getSettings());
} }
return output; return output;
}, },
render: async (markup, options) => { render: async (markup, options) => {
const { settings, getSettingsChanged } = await prepareRenderer(options); const { getSettings, getSettingsChanged } = await prepareRenderer(options);
const output = await renderer.render(markup, settings); const output = await renderer.render(markup, getSettings());
if (getSettingsChanged()) { if (getSettingsChanged()) {
return await renderer.render(markup, settings); return await renderer.render(markup, getSettings());
} }
return output; return output;
}, },