docgen-tool 5.3.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/app.tsx +18 -0
- package/dist/app/common/markdown/markdown.ts +27 -0
- package/dist/app/favicon.svg +4 -0
- package/dist/app/index.html +13 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-footer/pdf-footer.tsx +35 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-html-block/custom-renderers/custom-renderers.tsx +45 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-html-block/pdf-html-block.tsx +19 -0
- package/dist/app/pdf/react-pdf/pdf-page/pdf-page.tsx +22 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-admonitions-styles.ts +37 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-docs-styles.ts +94 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-styles.ts +154 -0
- package/dist/app/pdf/react-pdf/pdf-styles/pdf-table-styles.ts +21 -0
- package/dist/app/pdf/react-pdf/react-pdf.tsx +107 -0
- package/dist/app/style-variables/css/style-variables.css +80 -0
- package/dist/app/style-variables/js/style-variables.js +78 -0
- package/dist/app/views/assets/styles/fonts/archivo-600-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-600-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-600.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-600.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-regular.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/archivo-regular.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-600.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-600.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-regular.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-grotesk-regular.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-700.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-italic.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-italic.woff2 +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-regular.ttf +0 -0
- package/dist/app/views/assets/styles/fonts/space-mono-regular.woff2 +0 -0
- package/dist/{include/require → app/views/assets}/styles/framework.css +69 -36
- package/dist/app/views/components/copyright/copyright.tsx +16 -0
- package/dist/app/views/components/footer/footer.tsx +37 -0
- package/dist/app/views/components/logo/logo.tsx +13 -0
- package/dist/app/views/components/page/page.tsx +15 -0
- package/dist/app/views/components/pdf-footer/pdf-footer.tsx +29 -0
- package/dist/app/views/components/pdf-header/pdf-header.tsx +12 -0
- package/dist/app/views/components/pdf-toggle-button/pdf-toggle-button.tsx +41 -0
- package/dist/app/views/components/side-bar/side-bar.tsx +89 -0
- package/dist/app/views/components/top-bar/top-bar.tsx +62 -0
- package/dist/app/views/content/markdown.tsx +60 -0
- package/dist/app/views/content/page.tsx +6 -0
- package/dist/app/views/html.tsx +5 -0
- package/dist/app/views/load-pages.ts +27 -0
- package/dist/app/views/pages/cover/cover.css +39 -0
- package/dist/app/views/pages/cover/cover.tsx +99 -0
- package/dist/app/views/pages/main/main.tsx +42 -0
- package/dist/app/views/pages/main/pdf-viewer.tsx +18 -0
- package/dist/app/views/router.tsx +142 -0
- package/dist/cli/cli.js +293 -0
- package/package.json +25 -19
- package/dist/cli.js +0 -1253
- package/dist/include/require/styles/fonts/DroidSansMono.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-Italic.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-Regular.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-SemiBold.woff +0 -0
- package/dist/include/require/styles/fonts/Montserrat-SemiBoldItalic.woff +0 -0
- package/dist/include/require/styles/framework.js +0 -39
- package/dist/include/require/styles/icons.js +0 -9
- package/dist/include/templates/main.html +0 -14
- package/dist/include/templates/redirect.html +0 -10
- /package/dist/{include/require → app/views/assets}/print.css +0 -0
- /package/dist/{include/example → template}/contents.json +0 -0
- /package/dist/{include/example → template}/files/images/logo.svg +0 -0
- /package/dist/{include/example → template}/index.md +0 -0
- /package/dist/{include/example → template}/parameters.json +0 -0
- /package/dist/{include/example → template}/release-notes.md +0 -0
package/dist/app/app.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import { RouterProvider } from '@tanstack/react-router';
|
|
4
|
+
import { router } from './views/router.tsx';
|
|
5
|
+
import './views/assets/styles/framework.css';
|
|
6
|
+
|
|
7
|
+
const app = () => {
|
|
8
|
+
const rootElement = document.getElementById('root');
|
|
9
|
+
|
|
10
|
+
if (!rootElement) {
|
|
11
|
+
throw new Error('Root element not found');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
15
|
+
root.render(<RouterProvider router={router} />);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
app();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Quick-fix way to get the old markdown-it-admon implementation working still
|
|
3
|
+
in the new React SPA implementation (since we now use react-markdown on
|
|
4
|
+
the frontend and marked for the PDF pipeline, we need to preprocess
|
|
5
|
+
something that works with both. This could use a review and better
|
|
6
|
+
implementation later).
|
|
7
|
+
*/
|
|
8
|
+
export const preprocessAdmonitions = (markdown: string) => {
|
|
9
|
+
return markdown.replace(
|
|
10
|
+
/^!!!\s*(\w+)\s*(.*)\n((?: {4}.*\n?)+)/gm,
|
|
11
|
+
(_, type, title, content) => {
|
|
12
|
+
// remove 4-space indentation only from content lines
|
|
13
|
+
const cleanedContent = content
|
|
14
|
+
.split('\n')
|
|
15
|
+
.map((line) => line.replace(/^ {4}/, ''))
|
|
16
|
+
.join('\n');
|
|
17
|
+
|
|
18
|
+
// ensure blank line before/after content to preserve hr rendering
|
|
19
|
+
return `<div class="admonition ${type.toLowerCase()}">
|
|
20
|
+
<p class="admonition-title">${title}</p>
|
|
21
|
+
<p>${cleanedContent}</p>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
`;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M149.086 35.874V99.7005L193.607 121.141L126.625 153.843V220.856L246.976 160.681C252.391 157.989 255.794 152.451 255.794 146.418V99.1436C255.794 93.1106 252.391 87.5725 246.976 84.8809L149.086 35.9359V35.874Z" fill="#010203"/>
|
|
3
|
+
<path d="M129.966 35.8715L9.6144 96.0472C4.20013 98.7388 0.796875 104.277 0.796875 110.31V157.584C0.796875 163.617 4.20013 169.155 9.6144 171.847L107.504 220.792V153.779L62.9836 132.338L129.966 99.6361V35.8096V35.8715Z" fill="#010203"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>%APP_TITLE%</title>
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="./favicon.svg" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="app.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, StyleSheet } from '@react-pdf/renderer';
|
|
3
|
+
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
footer: {
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
bottom: 5,
|
|
8
|
+
left: 30,
|
|
9
|
+
right: 30,
|
|
10
|
+
height: 50,
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
justifyContent: 'space-between',
|
|
13
|
+
borderTopWidth: 1,
|
|
14
|
+
borderTopColor: 'black',
|
|
15
|
+
paddingTop: 10,
|
|
16
|
+
},
|
|
17
|
+
column: {
|
|
18
|
+
width: '33%',
|
|
19
|
+
textAlign: 'center',
|
|
20
|
+
fontSize: 10,
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const PdfFooter = ({parameters}) => (
|
|
25
|
+
<View style={styles.footer} fixed>
|
|
26
|
+
<Text style={styles.column}>{parameters.title}</Text>
|
|
27
|
+
<Text style={styles.column}>{`© ${parameters.year} ${parameters.name}`}</Text>
|
|
28
|
+
<Text
|
|
29
|
+
style={styles.column}
|
|
30
|
+
render={({ pageNumber, totalPages }) => (
|
|
31
|
+
`${pageNumber} / ${totalPages}`
|
|
32
|
+
)}
|
|
33
|
+
/>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
//import path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
Image,
|
|
7
|
+
} from '@react-pdf/renderer';
|
|
8
|
+
import * as cheerio from 'cheerio';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
For "default" renderers in react-pdf-html, see
|
|
12
|
+
|
|
13
|
+
renderBlock: <View style={style}>{children}</View>
|
|
14
|
+
renderInline: <Text style={style}>{children}</Text>
|
|
15
|
+
|
|
16
|
+
(and renderers.tsx for more details)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export const customRenderers = ({options}) => ({
|
|
20
|
+
div: (payload) => {
|
|
21
|
+
const {children, style, element} = payload;
|
|
22
|
+
const classNames = element.classList.toString();
|
|
23
|
+
if (classNames.includes("dgPDFPageBreak")) {
|
|
24
|
+
return <View break style={style}>{children}</View>;
|
|
25
|
+
}
|
|
26
|
+
return <View style={style}>{children}</View>;
|
|
27
|
+
},
|
|
28
|
+
pre: (payload) => {
|
|
29
|
+
const {children, element, style} = payload;
|
|
30
|
+
//strip and handle code blocks
|
|
31
|
+
const $ = cheerio.load(element.content.join());
|
|
32
|
+
const code = $('code');
|
|
33
|
+
if (code.length) {
|
|
34
|
+
return <Text style={style}>{code.text().trim()}</Text>;
|
|
35
|
+
}
|
|
36
|
+
return <Text style={style}>{children}</Text>;
|
|
37
|
+
},
|
|
38
|
+
// TODO: reinstate images without path
|
|
39
|
+
// img: (payload) => {
|
|
40
|
+
// const {element, style} = payload;
|
|
41
|
+
// const relativeSource = element.attributes.src;
|
|
42
|
+
// //const source = path.join(options.input, relativeSource);
|
|
43
|
+
// return <Image style={style} source={source} />;
|
|
44
|
+
// },
|
|
45
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Html from 'react-pdf-html';
|
|
3
|
+
import { fontSize, htmlStyleSheet } from '../../pdf-styles/pdf-styles.ts';
|
|
4
|
+
import { customRenderers } from "./custom-renderers/custom-renderers.tsx";
|
|
5
|
+
|
|
6
|
+
export const PdfHtmlBlock = ({
|
|
7
|
+
page,
|
|
8
|
+
options
|
|
9
|
+
}) => {
|
|
10
|
+
return (
|
|
11
|
+
<Html
|
|
12
|
+
style={{ fontSize }}
|
|
13
|
+
stylesheet={htmlStyleSheet}
|
|
14
|
+
renderers={customRenderers({options})}
|
|
15
|
+
>
|
|
16
|
+
{page}
|
|
17
|
+
</Html>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Page, View, StyleSheet } from '@react-pdf/renderer';
|
|
3
|
+
import { PdfHtmlBlock } from "./pdf-html-block/pdf-html-block.tsx";
|
|
4
|
+
import { PdfFooter } from './pdf-footer/pdf-footer.tsx';
|
|
5
|
+
import { pdfStyleSheet } from '../pdf-styles/pdf-styles.ts';
|
|
6
|
+
|
|
7
|
+
export const reactPdfStyles = StyleSheet.create(pdfStyleSheet);
|
|
8
|
+
|
|
9
|
+
export const PdfPage = ({
|
|
10
|
+
page,
|
|
11
|
+
parameters,
|
|
12
|
+
options
|
|
13
|
+
}) => {
|
|
14
|
+
return (
|
|
15
|
+
<Page size="A4" style={reactPdfStyles.page}>
|
|
16
|
+
<View>
|
|
17
|
+
<PdfHtmlBlock page={page} options={options} />
|
|
18
|
+
</View>
|
|
19
|
+
<PdfFooter parameters={parameters}/>
|
|
20
|
+
</Page>
|
|
21
|
+
)
|
|
22
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as styles from '../../../style-variables/js/style-variables';
|
|
2
|
+
|
|
3
|
+
const admonitionBaseStyle = {
|
|
4
|
+
padding: styles.SizeContentBlockPaddingPdf,
|
|
5
|
+
margin: styles.SizeContentBlockMarginPdf,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const pdfAdmonitionsStyles = {
|
|
9
|
+
blockquote: {
|
|
10
|
+
...admonitionBaseStyle,
|
|
11
|
+
backgroundColor: styles.ColorBackgroundNeutral,
|
|
12
|
+
borderLeft: `${styles.SizeAdmonitionBorderLeftPdf} solid ${styles.ColorBorderNeutral}`,
|
|
13
|
+
color: styles.ColorBorderNeutral,
|
|
14
|
+
fontStyle: 'italic',
|
|
15
|
+
},
|
|
16
|
+
['.admonition']: admonitionBaseStyle,
|
|
17
|
+
['.admonition-title']: {
|
|
18
|
+
margin: styles.SizeAdmonitionTitleMarginPdf,
|
|
19
|
+
fontWeight: 'bold',
|
|
20
|
+
},
|
|
21
|
+
['.admonition.information']: {
|
|
22
|
+
backgroundColor: styles.ColorBackgroundInfo,
|
|
23
|
+
borderLeft: `${styles.SizeAdmonitionBorderLeftPdf} solid ${styles.ColorBorderInfo}`,
|
|
24
|
+
},
|
|
25
|
+
['.admonition.success']: {
|
|
26
|
+
backgroundColor: styles.ColorBackgroundSuccess,
|
|
27
|
+
borderLeft: `${styles.SizeAdmonitionBorderLeftPdf} solid ${styles.ColorBorderSuccess}`,
|
|
28
|
+
},
|
|
29
|
+
['.admonition.warning']: {
|
|
30
|
+
backgroundColor: styles.ColorBackgroundWarning,
|
|
31
|
+
borderLeft: `${styles.SizeAdmonitionBorderLeftPdf} solid ${styles.ColorBorderWarning}`,
|
|
32
|
+
},
|
|
33
|
+
['.admonition.error']: {
|
|
34
|
+
backgroundColor: styles.ColorBackgroundError,
|
|
35
|
+
borderLeft: `${styles.SizeAdmonitionBorderLeftPdf} solid ${styles.ColorBorderError}`,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Todo: lift props to style dictionary
|
|
2
|
+
|
|
3
|
+
export const docsStyleSheet = {
|
|
4
|
+
// Features cards
|
|
5
|
+
['.banner h1']: {
|
|
6
|
+
fontFamily: 'space-grotesk',
|
|
7
|
+
},
|
|
8
|
+
['.features']: {
|
|
9
|
+
padding: 0,
|
|
10
|
+
width: '100%',
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
flexWrap: 'wrap',
|
|
14
|
+
justifyContent: 'flex-start',
|
|
15
|
+
gap: 20,
|
|
16
|
+
margin: '0 0 0.5cm',
|
|
17
|
+
},
|
|
18
|
+
['.features li']: {
|
|
19
|
+
listStyleType: 'none',
|
|
20
|
+
verticalAlign: 'top',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexDirection: 'column',
|
|
23
|
+
alignItems: 'flex-start',
|
|
24
|
+
width: '5cm',
|
|
25
|
+
margin: '0.5cm 0.5cm 0 0',
|
|
26
|
+
},
|
|
27
|
+
['.features li p']: {
|
|
28
|
+
margin: 0,
|
|
29
|
+
padding: '0 0 0.4cm 0',
|
|
30
|
+
textAlign: 'left',
|
|
31
|
+
},
|
|
32
|
+
['.features li img']: {
|
|
33
|
+
alignSelf: 'flex-start',
|
|
34
|
+
height: '1cm',
|
|
35
|
+
objectFit: 'contain', // preserve aspect ratio
|
|
36
|
+
marginBottom: '0.4cm',
|
|
37
|
+
},
|
|
38
|
+
// Feature details container
|
|
39
|
+
['.featureDetailsContainer']: {
|
|
40
|
+
display: 'flex',
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
justifyContent: 'flex-start',
|
|
43
|
+
alignItems: 'flex-start',
|
|
44
|
+
gap: '0.5cm',
|
|
45
|
+
padding: '0.5cm 0',
|
|
46
|
+
},
|
|
47
|
+
['.featureDetails']: {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexDirection: 'column',
|
|
50
|
+
width: '7cm',
|
|
51
|
+
},
|
|
52
|
+
// How it works cards
|
|
53
|
+
['.dgCardContainer']: {
|
|
54
|
+
display: 'flex',
|
|
55
|
+
flexDirection: 'row',
|
|
56
|
+
flexWrap: 'wrap',
|
|
57
|
+
justifyContent: 'flex-start',
|
|
58
|
+
gap: '0.5cm',
|
|
59
|
+
},
|
|
60
|
+
['.dgCard']: {
|
|
61
|
+
display: 'flex',
|
|
62
|
+
flexDirection: 'column',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
textAlign: 'left',
|
|
65
|
+
maxWidth: '5.5cm',
|
|
66
|
+
},
|
|
67
|
+
['.dgCard img']: {
|
|
68
|
+
width: '5.5cm',
|
|
69
|
+
height: 'auto',
|
|
70
|
+
borderRadius: '0.1cm',
|
|
71
|
+
},
|
|
72
|
+
['.dgCard p']: {
|
|
73
|
+
marginTop: '0.5cm',
|
|
74
|
+
wordWrap: 'break-word',
|
|
75
|
+
},
|
|
76
|
+
// Sponsor cards
|
|
77
|
+
['.inkitSponsor']: {
|
|
78
|
+
display: 'flex',
|
|
79
|
+
flexDirection: 'row',
|
|
80
|
+
padding: '10 0',
|
|
81
|
+
},
|
|
82
|
+
['.inkitText']: {
|
|
83
|
+
flex: 1,
|
|
84
|
+
justifyContent: 'left',
|
|
85
|
+
},
|
|
86
|
+
['.inkitImage']: {
|
|
87
|
+
flex: 1,
|
|
88
|
+
alignItems: 'left',
|
|
89
|
+
},
|
|
90
|
+
['.inkitImage img']: {
|
|
91
|
+
width: 200,
|
|
92
|
+
borderRadius: 8,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as styles from '../../../style-variables/js/style-variables';
|
|
2
|
+
import { docsStyleSheet } from './pdf-docs-styles.ts';
|
|
3
|
+
import { pdfAdmonitionsStyles } from './pdf-admonitions-styles.ts';
|
|
4
|
+
import { pdfTableStyles } from './pdf-table-styles.js';
|
|
5
|
+
|
|
6
|
+
export const fontSize = 10;
|
|
7
|
+
|
|
8
|
+
export const pdfStyleSheet = {
|
|
9
|
+
page: {
|
|
10
|
+
paddingTop: 35,
|
|
11
|
+
paddingBottom: 65,
|
|
12
|
+
paddingHorizontal: 35,
|
|
13
|
+
fontSize,
|
|
14
|
+
fontFamily: 'archivo',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const em = (em: number, relativeSize: number = fontSize) =>
|
|
19
|
+
em * relativeSize;
|
|
20
|
+
|
|
21
|
+
const styleInfo = {
|
|
22
|
+
color: styles.ColorTextInfo,
|
|
23
|
+
backgroundColor: styles.ColorBackgroundInfo,
|
|
24
|
+
borderLeft: `5px solid ${styles.ColorBorderInfo}`,
|
|
25
|
+
padding: styles.SizeMessagePadding,
|
|
26
|
+
marginLeft: 0,
|
|
27
|
+
marginRight: 0,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
See also the base styles set by react-pdf-html, which are being overridden here
|
|
32
|
+
https://github.com/danomatic/react-pdf-html/blob/main/src/styles.ts
|
|
33
|
+
*/
|
|
34
|
+
export const htmlStyleSheet = {
|
|
35
|
+
'h1, h2, h3, h4, h5, h6': {
|
|
36
|
+
fontWeight: 'bold',
|
|
37
|
+
},
|
|
38
|
+
h1: {
|
|
39
|
+
fontSize: styles.SizeFontH1Pdf,
|
|
40
|
+
marginVertical: em(0.67, em(2)),
|
|
41
|
+
},
|
|
42
|
+
h2: {
|
|
43
|
+
fontSize: styles.SizeFontH2Pdf,
|
|
44
|
+
marginVertical: em(0.83, em(1.5)),
|
|
45
|
+
},
|
|
46
|
+
h3: {
|
|
47
|
+
fontSize: styles.SizeFontH3Pdf,
|
|
48
|
+
marginVertical: em(1, em(1.17)),
|
|
49
|
+
},
|
|
50
|
+
h4: {
|
|
51
|
+
fontSize: styles.SizeFontH4Pdf,
|
|
52
|
+
marginVertical: em(1.33, em(1)),
|
|
53
|
+
},
|
|
54
|
+
h5: {
|
|
55
|
+
fontSize: styles.SizeFontH5Pdf,
|
|
56
|
+
marginVertical: em(1.67, em(0.83)),
|
|
57
|
+
},
|
|
58
|
+
h6: {
|
|
59
|
+
fontSize: styles.SizeFontH6Pdf,
|
|
60
|
+
marginVertical: em(2.33, em(0.67)),
|
|
61
|
+
},
|
|
62
|
+
p: {
|
|
63
|
+
color: styles.ColorText,
|
|
64
|
+
fontSize: em(1),
|
|
65
|
+
marginVertical: em(1),
|
|
66
|
+
},
|
|
67
|
+
hr: {
|
|
68
|
+
marginVertical: em(0.5),
|
|
69
|
+
borderBottomWidth: 1,
|
|
70
|
+
borderBottomColor: '#000',
|
|
71
|
+
},
|
|
72
|
+
address: {
|
|
73
|
+
fontStyle: 'italic',
|
|
74
|
+
},
|
|
75
|
+
pre: {
|
|
76
|
+
fontSize: '10pt',
|
|
77
|
+
fontFamily: 'space-mono',
|
|
78
|
+
backgroundColor: '#f5f5f5',
|
|
79
|
+
color: '#333333',
|
|
80
|
+
borderRadius: '4pt',
|
|
81
|
+
padding: '8pt',
|
|
82
|
+
borderLeft: '4pt solid #cccccc',
|
|
83
|
+
marginVertical: em(1),
|
|
84
|
+
whiteSpace: 'pre-wrap',
|
|
85
|
+
},
|
|
86
|
+
b: {
|
|
87
|
+
fontWeight: 'bold',
|
|
88
|
+
},
|
|
89
|
+
strong: {
|
|
90
|
+
fontWeight: 'bold',
|
|
91
|
+
},
|
|
92
|
+
i: {
|
|
93
|
+
fontStyle: 'italic',
|
|
94
|
+
},
|
|
95
|
+
em: {
|
|
96
|
+
fontStyle: 'italic',
|
|
97
|
+
},
|
|
98
|
+
s: {
|
|
99
|
+
textDecoration: 'line-through',
|
|
100
|
+
},
|
|
101
|
+
u: {
|
|
102
|
+
textDecoration: 'underline',
|
|
103
|
+
},
|
|
104
|
+
cite: {
|
|
105
|
+
fontStyle: 'italic',
|
|
106
|
+
},
|
|
107
|
+
code: {
|
|
108
|
+
fontFamily: 'space-mono',
|
|
109
|
+
},
|
|
110
|
+
a: {
|
|
111
|
+
textDecoration: 'underline',
|
|
112
|
+
},
|
|
113
|
+
ul: {
|
|
114
|
+
marginVertical: em(1),
|
|
115
|
+
},
|
|
116
|
+
ol: {
|
|
117
|
+
marginVertical: em(1),
|
|
118
|
+
},
|
|
119
|
+
li: {
|
|
120
|
+
display: 'flex',
|
|
121
|
+
flexDirection: 'row',
|
|
122
|
+
},
|
|
123
|
+
li_bullet: {
|
|
124
|
+
width: 30,
|
|
125
|
+
textAlign: 'right',
|
|
126
|
+
flexShrink: 0,
|
|
127
|
+
flexGrow: 0,
|
|
128
|
+
paddingRight: 5,
|
|
129
|
+
},
|
|
130
|
+
li_content: {
|
|
131
|
+
textAlign: 'left',
|
|
132
|
+
flexGrow: 1,
|
|
133
|
+
flexBasis: 1,
|
|
134
|
+
},
|
|
135
|
+
thead: {
|
|
136
|
+
display: 'flex',
|
|
137
|
+
flexDirection: 'column',
|
|
138
|
+
},
|
|
139
|
+
tbody: {
|
|
140
|
+
display: 'flex',
|
|
141
|
+
flexDirection: 'column',
|
|
142
|
+
},
|
|
143
|
+
tr: {
|
|
144
|
+
display: 'flex',
|
|
145
|
+
flexDirection: 'row',
|
|
146
|
+
flexShrink: 1,
|
|
147
|
+
},
|
|
148
|
+
['.button']: {
|
|
149
|
+
textAlign: 'center',
|
|
150
|
+
},
|
|
151
|
+
...pdfAdmonitionsStyles,
|
|
152
|
+
...pdfTableStyles,
|
|
153
|
+
...docsStyleSheet,
|
|
154
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as styles from '../../../style-variables/js/style-variables';
|
|
2
|
+
|
|
3
|
+
const tableCellStyle = {
|
|
4
|
+
padding: styles.SizeTableCellPaddingPdf,
|
|
5
|
+
border: `${styles.SizeBorderWidthPdf} solid ${styles.ColorBorder}`,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const tableHeaderFooterStyle = {
|
|
9
|
+
...tableCellStyle,
|
|
10
|
+
backgroundColor: styles.ColorTableBackgroundHeaderFooterPdf,
|
|
11
|
+
fontWeight: 'bold',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const pdfTableStyles = {
|
|
15
|
+
table: {
|
|
16
|
+
border: '1px solid #ccc',
|
|
17
|
+
},
|
|
18
|
+
td: tableCellStyle,
|
|
19
|
+
th: tableHeaderFooterStyle,
|
|
20
|
+
['tfoot td']: tableHeaderFooterStyle,
|
|
21
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Document, Font } from '@react-pdf/renderer';
|
|
3
|
+
import { PdfPage } from './pdf-page/pdf-page.tsx';
|
|
4
|
+
import { marked } from 'marked';
|
|
5
|
+
|
|
6
|
+
import archivoRegular from '../../views/assets/styles/fonts/archivo-regular.ttf';
|
|
7
|
+
import archivoItalic from '../../views/assets/styles/fonts/archivo-italic.ttf';
|
|
8
|
+
import archivo600 from '../../views/assets/styles/fonts/archivo-600.ttf';
|
|
9
|
+
import archivo600Italic from '../../views/assets/styles/fonts/archivo-600-italic.ttf';
|
|
10
|
+
|
|
11
|
+
import spaceGroteskRegular from '../../views/assets/styles/fonts/space-grotesk-regular.ttf';
|
|
12
|
+
import spaceGrotesk600 from '../../views/assets/styles/fonts/space-grotesk-600.ttf';
|
|
13
|
+
|
|
14
|
+
import spaceMonoRegular from '../../views/assets/styles/fonts/space-mono-regular.ttf';
|
|
15
|
+
import spaceMonoItalic from '../../views/assets/styles/fonts/space-mono-italic.ttf';
|
|
16
|
+
import spaceMono700 from '../../views/assets/styles/fonts/space-mono-700.ttf';
|
|
17
|
+
import spaceMono700Italic from '../../views/assets/styles/fonts/space-mono-700-italic.ttf';
|
|
18
|
+
import type { TParameters, TSortedPages, TSection } from '../../../docgen/types.ts';
|
|
19
|
+
import { preprocessAdmonitions } from '../../common/markdown/markdown.ts';
|
|
20
|
+
|
|
21
|
+
declare const __BASE_PATH__: string;
|
|
22
|
+
|
|
23
|
+
Font.register({
|
|
24
|
+
family: 'archivo',
|
|
25
|
+
fonts: [
|
|
26
|
+
{ src: archivoRegular, fontStyle: 'normal', fontWeight: 400 },
|
|
27
|
+
{ src: archivoItalic, fontStyle: 'italic', fontWeight: 400 },
|
|
28
|
+
{ src: archivo600, fontStyle: 'normal', fontWeight: 600 },
|
|
29
|
+
{ src: archivo600Italic, fontStyle: 'italic', fontWeight: 600 },
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Font.register({
|
|
34
|
+
family: 'space-grotesk',
|
|
35
|
+
fonts: [
|
|
36
|
+
{ src: spaceGroteskRegular, fontStyle: 'normal', fontWeight: 400 },
|
|
37
|
+
{ src: spaceGrotesk600, fontStyle: 'normal', fontWeight: 600 },
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
Font.register({
|
|
42
|
+
family: 'space-mono',
|
|
43
|
+
fonts: [
|
|
44
|
+
{ src: spaceMonoRegular, fontStyle: 'normal', fontWeight: 400 },
|
|
45
|
+
{ src: spaceMonoItalic, fontStyle: 'italic', fontWeight: 400 },
|
|
46
|
+
{ src: spaceMono700, fontStyle: 'normal', fontWeight: 700 },
|
|
47
|
+
{ src: spaceMono700Italic, fontStyle: 'italic', fontWeight: 700 },
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
type PdfProps = {
|
|
52
|
+
parameters: TParameters;
|
|
53
|
+
options: any;
|
|
54
|
+
sortedPages: TSortedPages;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Async loader for PDF pages
|
|
58
|
+
const loadPdfPages = async (sortedPages: any): Promise<Record<string, string>> => {
|
|
59
|
+
const pages: Record<string, string> = {};
|
|
60
|
+
|
|
61
|
+
const sources = Object.values(sortedPages)
|
|
62
|
+
.flatMap((columns: TSection) =>
|
|
63
|
+
columns.flatMap((section) => section.pages.map((p: any) => p.source)),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
await Promise.all(
|
|
67
|
+
sources.map(async (filename) => {
|
|
68
|
+
const url = `${__BASE_PATH__}${filename}`;
|
|
69
|
+
try {
|
|
70
|
+
const res = await fetch(url);
|
|
71
|
+
pages[filename] = res.ok ? await res.text() : `Error loading ${filename}: ${res.status}`;
|
|
72
|
+
} catch (err) {
|
|
73
|
+
pages[filename] = `Error loading ${filename}: ${err}`;
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return pages;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Pdf = ({ parameters, options, sortedPages }: PdfProps) => {
|
|
82
|
+
const [pages, setPages] = useState<Record<string, string>>({});
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const fetchPages = async () => {
|
|
86
|
+
const loaded = await loadPdfPages(sortedPages);
|
|
87
|
+
setPages(loaded);
|
|
88
|
+
};
|
|
89
|
+
fetchPages();
|
|
90
|
+
}, [sortedPages]);
|
|
91
|
+
|
|
92
|
+
const allSources = Object.values(sortedPages)
|
|
93
|
+
.flatMap((columns) =>
|
|
94
|
+
columns.flatMap((section) => section.pages.map((p: any) => p.source)),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Document>
|
|
99
|
+
{allSources.map((source, i) => {
|
|
100
|
+
const html = marked(preprocessAdmonitions(pages[source] || ''));
|
|
101
|
+
return (
|
|
102
|
+
<PdfPage key={i} page={html} parameters={parameters} options={options} />
|
|
103
|
+
);
|
|
104
|
+
})}
|
|
105
|
+
</Document>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not edit directly, this file was auto-generated.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--color-primary: rgb(46, 113, 225);
|
|
7
|
+
--color-primary-light: rgb(222, 232, 252);
|
|
8
|
+
--color-primary-dark: rgb(22, 71, 193);
|
|
9
|
+
--color-background-light: #fff;
|
|
10
|
+
--color-background-success: #e8f5e9;
|
|
11
|
+
--color-background-error: #ffebee;
|
|
12
|
+
--color-background-warning: #fff8e1;
|
|
13
|
+
--color-background-info: rgb(222, 232, 252);
|
|
14
|
+
--color-background-neutral: #f5f5f5;
|
|
15
|
+
--color-border: #999;
|
|
16
|
+
--color-border-success: #4caf50;
|
|
17
|
+
--color-border-error: #f44336;
|
|
18
|
+
--color-border-warning: #ff9800;
|
|
19
|
+
--color-border-info: #81a7f4;
|
|
20
|
+
--color-border-neutral: #9e9e9e;
|
|
21
|
+
--color-text: rgb(1, 3, 4);
|
|
22
|
+
--color-text-light: #bbb;
|
|
23
|
+
--color-text-neutral: #333;
|
|
24
|
+
--color-text-success: #2ab100;
|
|
25
|
+
--color-text-error: #c20000;
|
|
26
|
+
--color-text-warning: #b28900;
|
|
27
|
+
--color-text-info: #0a2a6b;
|
|
28
|
+
--color-text-link: rgb(1, 3, 4);
|
|
29
|
+
--color-text-link-hover: #4a72c1;
|
|
30
|
+
--color-text-link-active: #4b91ff;
|
|
31
|
+
--color-text-link-visited: #808080;
|
|
32
|
+
--color-button-border: 2px solid rgb(46, 113, 225);
|
|
33
|
+
--color-button-border-inverted: 2px solid rgb(46, 113, 225);
|
|
34
|
+
--color-button-background: rgb(46, 113, 225);
|
|
35
|
+
--color-button-background-hover: #0042b4;
|
|
36
|
+
--color-button-background-inverted: #fff;
|
|
37
|
+
--color-button-text: #fff;
|
|
38
|
+
--color-button-text-inverted: rgb(46, 113, 225);
|
|
39
|
+
--color-button-shadow: none;
|
|
40
|
+
--color-table-background: #eee;
|
|
41
|
+
--color-table-background-header-footer: #ddd;
|
|
42
|
+
--color-table-background-header-footer-pdf: #eee;
|
|
43
|
+
--size-border-width: 1px;
|
|
44
|
+
--size-border-width-pdf: 0.8pt;
|
|
45
|
+
--size-button-base: 42px;
|
|
46
|
+
--size-font-base: 16px;
|
|
47
|
+
--size-font-small: 12px;
|
|
48
|
+
--size-font-medium: 16px;
|
|
49
|
+
--size-font-large: 24px;
|
|
50
|
+
--size-font-h1: 2rem;
|
|
51
|
+
--size-font-h1-pdf: 24pt;
|
|
52
|
+
--size-font-h2: 1.5rem;
|
|
53
|
+
--size-font-h2-pdf: 20pt;
|
|
54
|
+
--size-font-h3: 1.25rem;
|
|
55
|
+
--size-font-h3-pdf: 18pt;
|
|
56
|
+
--size-font-h4: 1rem;
|
|
57
|
+
--size-font-h4-pdf: 16pt;
|
|
58
|
+
--size-font-h5: 0.875rem;
|
|
59
|
+
--size-font-h5-pdf: 14pt;
|
|
60
|
+
--size-font-h6: 0.75rem;
|
|
61
|
+
--size-font-h6-pdf: 12pt;
|
|
62
|
+
--size-line-height: 26px;
|
|
63
|
+
--size-table-cell-padding: 2px 15px;
|
|
64
|
+
--size-table-cell-padding-pdf: 2mm 2mm;
|
|
65
|
+
--size-content-block-margin: 1.5em 0;
|
|
66
|
+
--size-content-block-margin-pdf: 2mm 0;
|
|
67
|
+
--size-content-block-padding: 0.8rem 1rem;
|
|
68
|
+
--size-content-block-padding-pdf: 1mm 4mm;
|
|
69
|
+
--size-admonition-border-left: 4px;
|
|
70
|
+
--size-admonition-border-left-pdf: 1mm;
|
|
71
|
+
--size-admonition-border-radius: 4px;
|
|
72
|
+
--size-admonition-title-margin: 0.1em 0 0;
|
|
73
|
+
--size-admonition-title-margin-pdf: 3mm 0 0;
|
|
74
|
+
--size-message-padding: 20px 30px;
|
|
75
|
+
--size-message-border-radius: 2px;
|
|
76
|
+
--size-header-height: 80px;
|
|
77
|
+
--size-side-bar-width: 330px;
|
|
78
|
+
--size-side-bar-min-width: 40px;
|
|
79
|
+
--size-side-bar-padding: 5px;
|
|
80
|
+
}
|