1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-desktop/gui/WindowCommandsAndDialogs/PluginDialogs.tsx
Henry Heino 4a88d6ff7a
Desktop: Multiple window support (#11181)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
2024-11-08 15:32:05 +00:00

46 lines
1.2 KiB
TypeScript

import * as React from 'react';
import UserWebviewDialog from '../../services/plugins/UserWebviewDialog';
import { PluginHtmlContents, PluginStates, utils as pluginUtils } from '@joplin/lib/services/plugins/reducer';
import { ContainerType } from '@joplin/lib/services/plugins/WebviewController';
import { VisibleDialogs } from '../../app.reducer';
interface Props {
themeId: number;
visibleDialogs: VisibleDialogs;
pluginHtmlContents: PluginHtmlContents;
plugins: PluginStates;
}
const PluginDialogs: React.FC<Props> = props => {
const output = [];
const infos = pluginUtils.viewInfosByType(props.plugins, 'webview');
for (const info of infos) {
const { plugin, view } = info;
if (view.containerType !== ContainerType.Dialog) continue;
if (!props.visibleDialogs[view.id]) continue;
const html = props.pluginHtmlContents[plugin.id]?.[view.id] ?? '';
output.push(<UserWebviewDialog
key={view.id}
viewId={view.id}
themeId={props.themeId}
html={html}
scripts={view.scripts}
pluginId={plugin.id}
buttons={view.buttons}
fitToContent={view.fitToContent}
/>);
}
if (!output.length) return null;
return (
<div className='user-webview-dialog-container'>
{output}
</div>
);
};
export default PluginDialogs;