diff --git a/packages/app-desktop/gui/MainScreen/MainScreen.tsx b/packages/app-desktop/gui/MainScreen/MainScreen.tsx index 5dbd38288..eb4bd48d0 100644 --- a/packages/app-desktop/gui/MainScreen/MainScreen.tsx +++ b/packages/app-desktop/gui/MainScreen/MainScreen.tsx @@ -8,7 +8,7 @@ import NoteEditor from '../NoteEditor/NoteEditor'; import NoteContentPropertiesDialog from '../NoteContentPropertiesDialog'; import ShareNoteDialog from '../ShareNoteDialog'; import CommandService from '@joplin/lib/services/CommandService'; -import { PluginStates, utils as pluginUtils } from '@joplin/lib/services/plugins/reducer'; +import { PluginHtmlContents, PluginStates, utils as pluginUtils } from '@joplin/lib/services/plugins/reducer'; import Sidebar from '../Sidebar/Sidebar'; import UserWebview from '../../services/plugins/UserWebview'; import UserWebviewDialog from '../../services/plugins/UserWebviewDialog'; @@ -53,6 +53,7 @@ interface LayerModalState { interface Props { plugins: PluginStates; + pluginHtmlContents: PluginHtmlContents; pluginsLoaded: boolean; hasNotesBeingSaved: boolean; dispatch: Function; @@ -723,12 +724,13 @@ class MainScreenComponent extends React.Component { } } else { const { view, plugin } = viewInfo; + const html = this.props.pluginHtmlContents[plugin.id]?.[view.id] ?? ''; return { const { plugin, view } = info; if (view.containerType !== ContainerType.Dialog) continue; if (!view.opened) continue; + const html = this.props.pluginHtmlContents[plugin.id]?.[view.id] ?? ''; output.push( { selectedNoteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null, pluginsLegacy: state.pluginsLegacy, plugins: state.pluginService.plugins, + pluginHtmlContents: state.pluginService.pluginHtmlContents, customCss: state.customCss, editorNoteStatuses: state.editorNoteStatuses, hasNotesBeingSaved: stateUtils.hasNotesBeingSaved(state), diff --git a/packages/lib/services/plugins/reducer.ts b/packages/lib/services/plugins/reducer.ts index ea9e75aef..6e732aef5 100644 --- a/packages/lib/services/plugins/reducer.ts +++ b/packages/lib/services/plugins/reducer.ts @@ -33,14 +33,24 @@ export interface PluginStates { [key: string]: PluginState; } +export interface PluginHtmlContent { + [viewId: string]: string; +} + +export interface PluginHtmlContents { + [pluginId: string]: PluginHtmlContent; +} + export interface State { plugins: PluginStates; + pluginHtmlContents: PluginHtmlContents; } export const stateRootKey = 'pluginService'; export const defaultState: State = { plugins: {}, + pluginHtmlContents: {}, }; export const utils = { @@ -139,7 +149,12 @@ const reducer = (draftRoot: Draft, action: any) => { case 'PLUGIN_VIEW_PROP_SET': - (draft.plugins[action.pluginId].views[action.id] as any)[action.name] = action.value; + if (action.name !== 'html') { + (draft.plugins[action.pluginId].views[action.id] as any)[action.name] = action.value; + } else { + draft.pluginHtmlContents[action.pluginId] ??= {}; + draft.pluginHtmlContents[action.pluginId][action.id] = action.value; + } break; case 'PLUGIN_VIEW_PROP_PUSH':