1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Desktop: Allow setting a max width for the editor content

This commit is contained in:
Laurent Cozic
2021-08-14 12:19:53 +01:00
parent a9961ae3ec
commit 8063c94ff7
9 changed files with 87 additions and 23 deletions

View File

@@ -7,11 +7,28 @@ function formatCssSize(v: any): string {
return `${v}px`;
}
export default function(theme: any) {
export interface Options {
contentMaxWidth?: number;
}
export default function(theme: any, options: Options = null) {
options = {
contentMaxWidth: 0,
...options,
};
theme = theme ? theme : {};
const fontFamily = '\'Avenir\', \'Arial\', sans-serif';
const maxWidthCss = options.contentMaxWidth ? `
#rendered-md {
max-width: ${options.contentMaxWidth}px;
margin-left: auto;
margin-right: auto;
}
` : '';
const css =
`
/* https://necolas.github.io/normalize.css/ */
@@ -61,6 +78,8 @@ export default function(theme: any) {
background: rgba(100, 100, 100, 0.7);
}
${maxWidthCss}
/* Remove top padding and margin from first child so that top of rendered text is aligned to top of text editor text */
#rendered-md > h1:first-child,