docgen-tool 6.1.0 → 6.2.0
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/pdf/pdf-generator/pdf-page/pdf-html-block/custom-renderers/custom-renderers.tsx +8 -1
- package/dist/app/pdf/pdf-viewer/pdf-viewer.module.css +7 -0
- package/dist/app/views/assets/styles/framework.css +9 -2
- package/dist/app/views/components/loader/loader.tsx +0 -1
- package/dist/app/views/content/code-block.module.css +35 -0
- package/dist/app/views/content/markdown.tsx +35 -1
- package/dist/cli/cli.js +21 -7
- package/package.json +1 -1
package/dist/app/pdf/pdf-generator/pdf-page/pdf-html-block/custom-renderers/custom-renderers.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { View, Text, Image } from '@react-pdf/renderer';
|
|
3
3
|
import * as cheerio from 'cheerio';
|
|
4
4
|
|
|
5
|
+
declare const __BASE_PATH__: string;
|
|
6
|
+
|
|
5
7
|
/*
|
|
6
8
|
For "default" renderers in react-pdf-html, see
|
|
7
9
|
|
|
@@ -37,6 +39,11 @@ export const customRenderers = ({ options }) => ({
|
|
|
37
39
|
img: (payload) => {
|
|
38
40
|
const { element, style } = payload;
|
|
39
41
|
// Load images from base URL
|
|
40
|
-
return
|
|
42
|
+
return (
|
|
43
|
+
<Image
|
|
44
|
+
style={style}
|
|
45
|
+
source={`${__BASE_PATH__}${element?.attributes?.src}`}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
41
48
|
},
|
|
42
49
|
});
|
|
@@ -644,7 +644,9 @@ li.list-heading {
|
|
|
644
644
|
section > div ul ul,
|
|
645
645
|
section > div ol ol {
|
|
646
646
|
margin: 0;
|
|
647
|
-
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/*don't put margin on nested lists*/
|
|
648
650
|
.w-small {
|
|
649
651
|
font-size: 12px;
|
|
650
652
|
}
|
|
@@ -731,8 +733,13 @@ pre {
|
|
|
731
733
|
padding: 12px;
|
|
732
734
|
background-color: #f3f3f3;
|
|
733
735
|
border: 1px solid var(--color-border);
|
|
734
|
-
line-height:
|
|
736
|
+
line-height: 1.5;
|
|
735
737
|
border-radius: 6px;
|
|
738
|
+
overflow-x: auto;
|
|
739
|
+
scrollbar-width: none;
|
|
740
|
+
}
|
|
741
|
+
pre::-webkit-scrollbar {
|
|
742
|
+
display: none;
|
|
736
743
|
}
|
|
737
744
|
|
|
738
745
|
.w-inline-code {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.codeBlockWrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.copyButton {
|
|
6
|
+
position: absolute;
|
|
7
|
+
top: 8px;
|
|
8
|
+
right: 8px;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
width: 28px;
|
|
13
|
+
height: 28px;
|
|
14
|
+
padding: 0;
|
|
15
|
+
border: none;
|
|
16
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
17
|
+
color: #fff;
|
|
18
|
+
border-radius: 14px;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: background-color 0.1s ease;
|
|
21
|
+
font-size: 16px;
|
|
22
|
+
opacity: 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.copyButton:hover {
|
|
26
|
+
background-color: rgba(0, 0, 0, 0.45);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.copyButton:active {
|
|
30
|
+
background-color: rgba(0, 0, 0, 0.55);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.copied {
|
|
34
|
+
opacity: 0.8;
|
|
35
|
+
}
|
|
@@ -1,14 +1,47 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import ReactMarkdown from 'react-markdown';
|
|
3
3
|
import remarkGfm from 'remark-gfm';
|
|
4
4
|
import rehypeRaw from 'rehype-raw';
|
|
5
5
|
import { Link } from '@tanstack/react-router';
|
|
6
|
+
import { TbCopy, TbCheck } from 'react-icons/tb';
|
|
6
7
|
import { preprocessAdmonitions } from '../../common/markdown/markdown.ts';
|
|
8
|
+
import styles from './code-block.module.css';
|
|
7
9
|
|
|
8
10
|
type Props = {
|
|
9
11
|
content: string;
|
|
10
12
|
};
|
|
11
13
|
|
|
14
|
+
const CodeBlock = ({ children, ...props }: any) => {
|
|
15
|
+
const [copied, setCopied] = useState(false);
|
|
16
|
+
|
|
17
|
+
const handleCopy = () => {
|
|
18
|
+
const codeElement = children?.props?.children;
|
|
19
|
+
const textContent =
|
|
20
|
+
typeof codeElement === 'string'
|
|
21
|
+
? codeElement
|
|
22
|
+
: codeElement?.toString() || '';
|
|
23
|
+
|
|
24
|
+
navigator.clipboard.writeText(textContent.trim()).then(() => {
|
|
25
|
+
setCopied(true);
|
|
26
|
+
setTimeout(() => setCopied(false), 2000);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className={styles.codeBlockWrapper}>
|
|
32
|
+
<button
|
|
33
|
+
className={`${styles.copyButton} ${copied ? styles.copied : ''}`}
|
|
34
|
+
onClick={handleCopy}
|
|
35
|
+
aria-label="Copy code"
|
|
36
|
+
title={copied ? 'Copied' : 'Copy code'}
|
|
37
|
+
>
|
|
38
|
+
{copied ? <TbCheck /> : <TbCopy />}
|
|
39
|
+
</button>
|
|
40
|
+
<pre {...props}>{children}</pre>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
12
45
|
export const Markdown = ({ content }: Props) => {
|
|
13
46
|
const preparedContent = preprocessAdmonitions(content);
|
|
14
47
|
return (
|
|
@@ -16,6 +49,7 @@ export const Markdown = ({ content }: Props) => {
|
|
|
16
49
|
remarkPlugins={[remarkGfm]}
|
|
17
50
|
rehypePlugins={[rehypeRaw]}
|
|
18
51
|
components={{
|
|
52
|
+
pre: CodeBlock,
|
|
19
53
|
a: ({ href, children, title, className }) => {
|
|
20
54
|
// no href -> render plain text anchor
|
|
21
55
|
if (!href) {
|
package/dist/cli/cli.js
CHANGED
|
@@ -256,12 +256,26 @@ const basePath = process.env.BASE_PATH || "/", generate = async (command, mode)
|
|
|
256
256
|
root: appPath,
|
|
257
257
|
publicDir: inputDir,
|
|
258
258
|
base: basePath,
|
|
259
|
-
plugins: [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
plugins: [
|
|
260
|
+
react({ exclude: /\/src\/app\/pdf\// }),
|
|
261
|
+
{
|
|
262
|
+
name: "html-transform",
|
|
263
|
+
transformIndexHtml(html) {
|
|
264
|
+
return html.replace(/%APP_TITLE%/g, parameters.title ?? "DocGen");
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
...mode !== "build" ? [{
|
|
268
|
+
name: "watch-input-dir",
|
|
269
|
+
configureServer(server) {
|
|
270
|
+
const watchPattern = path.join(inputDir, "**/*.{md,json,png}");
|
|
271
|
+
server.watcher.add(watchPattern);
|
|
272
|
+
const handleFileChange = (changedPath) => {
|
|
273
|
+
console.log(`Input file changed, reloading: ${path.relative(inputDir, changedPath)}`), server.ws.send({ type: "full-reload" });
|
|
274
|
+
};
|
|
275
|
+
server.watcher.on("add", handleFileChange), server.watcher.on("change", handleFileChange), server.watcher.on("unlink", handleFileChange);
|
|
276
|
+
}
|
|
277
|
+
}] : []
|
|
278
|
+
],
|
|
265
279
|
define: {
|
|
266
280
|
__DOCGEN_PARAMETERS__: JSON.stringify(parameters),
|
|
267
281
|
__DOCGEN_PAGES__: JSON.stringify(sortedPages),
|
|
@@ -283,7 +297,7 @@ const basePath = process.env.BASE_PATH || "/", generate = async (command, mode)
|
|
|
283
297
|
}, scaffold = async (command) => {
|
|
284
298
|
const inputDir = findTemplateDir(import.meta.dirname), outputDir = path.normalize(command.output + "/"), verbose = command.verbose === true;
|
|
285
299
|
console.log(pico.green("Creating scaffold template directory")), await copyDirectory(inputDir, outputDir, verbose);
|
|
286
|
-
}, version = "6.
|
|
300
|
+
}, version = "6.2.0";
|
|
287
301
|
if (program.version(version).usage("[command] [--option]"), program.command("scaffold").usage("[--option]").description("create a template input directory").option("-o, --output [path]", "path to the output directory (default: ./)", "./").option("-v, --verbose", "show verbose output including detailed errors").action((command) => {
|
|
288
302
|
scaffold(command);
|
|
289
303
|
}), program.command("dev").usage("[--option]").description("create a static website from an input directory").option("-i, --input [path]", "path to the input directory [default: ./]", "./").option("-o, --output [path]", "path to the output directory [default: ./output]", "./output").option("-p, --pdf", "create a PDF document").option("-s, --set-version [version]", "override parameters.version (useful for build tools) [default: false]", false).option("-R, --set-release-date [date]", "override parameters.date (useful for build tools) [default: false]", false).option("-v, --verbose", "show verbose output including detailed errors").action((command) => {
|