diff --git a/packages/app-cli/tests/support/plugins/dialog/src/index.ts b/packages/app-cli/tests/support/plugins/dialog/src/index.ts index 14f5f34581..6d0878b425 100644 --- a/packages/app-cli/tests/support/plugins/dialog/src/index.ts +++ b/packages/app-cli/tests/support/plugins/dialog/src/index.ts @@ -40,7 +40,24 @@ joplin.plugins.register({ `); const result3 = await dialogs.open(handle3); - console.info('Got result: ' + JSON.stringify(result3)); + console.info('Got result: ' + JSON.stringify(result3)); + + + const handle4 = await dialogs.create('myDialog4'); + await dialogs.setHtml(handle4, ` +

This dialog tests dynamic sizing

+

Resize the window and the dialog should resize accordingly

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum +

+ `); + let tmpDlg: any = dialogs; // Temporary cast to use new properties. + await tmpDlg.setFitToContent(handle4, false); + await dialogs.open(handle4); + }, }); diff --git a/packages/app-desktop/gui/MainScreen/MainScreen.tsx b/packages/app-desktop/gui/MainScreen/MainScreen.tsx index 8f5b3d1f90..455a66fca1 100644 --- a/packages/app-desktop/gui/MainScreen/MainScreen.tsx +++ b/packages/app-desktop/gui/MainScreen/MainScreen.tsx @@ -785,6 +785,7 @@ class MainScreenComponent extends React.Component { scripts={view.scripts} pluginId={plugin.id} buttons={view.buttons} + fitToContent={view.fitToContent} />); } diff --git a/packages/app-desktop/services/plugins/UserWebviewDialog.tsx b/packages/app-desktop/services/plugins/UserWebviewDialog.tsx index ff13a45e4c..39c2cb7ba8 100644 --- a/packages/app-desktop/services/plugins/UserWebviewDialog.tsx +++ b/packages/app-desktop/services/plugins/UserWebviewDialog.tsx @@ -9,6 +9,7 @@ const styled = require('styled-components').default; interface Props extends UserWebviewProps { buttons: ButtonSpec[]; + fitToContent: boolean; } const StyledRoot = styled.div` @@ -31,6 +32,8 @@ const Dialog = styled.div` padding: ${(props: any) => `${props.theme.mainPadding}px`}; border-radius: 4px; box-shadow: 0 6px 10px #00000077; + width: ${(props: any) => props.fitToContent ? 'auto' : '90vw'}; + height: ${(props: any) => props.fitToContent ? 'auto' : '80vh'}; `; const UserWebViewWrapper = styled.div` @@ -103,7 +106,7 @@ export default function UserWebviewDialog(props: Props) { return ( - +