Skip to content

Commit 7d2dbab

Browse files
committed
feat(toolbar): Add HTML export functionality
1 parent 26ee415 commit 7d2dbab

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

site/src/components/edit/toolbar/File.vue

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@
2929
<span i-ri:markdown-fill text-base />
3030
<span>{{ $t("toolbar.file.export_md") }}</span>
3131
</li>
32+
33+
<li class="dropdown-li space-x-1.5 rounded" role="button" @click="exportHtml">
34+
<span i-mdi:language-html5 text-base />
35+
<span>{{ $t("toolbar.file.export_html") }}</span>
36+
</li>
3237
</ToolItem>
3338
</template>
3439

3540
<script lang="ts" setup>
3641
import { downloadFile } from "@renovamen/utils";
3742
3843
const { data } = useDataStore();
44+
const { styles } = useStyleStore();
3945
const saveName = computed(() => data.curResumeName.trim().replace(/\s+/g, "_"));
4046
4147
const exportPDF = () => {
@@ -49,4 +55,71 @@ const exportPDF = () => {
4955
const exportMd = () => {
5056
downloadFile(`${saveName.value}.md`, data.mdContent);
5157
};
58+
59+
const exportHtml = () => {
60+
const html = renderMarkdown(data.mdContent);
61+
62+
// Generate dynamic CSS based on current styles
63+
const dynamicCss = `
64+
/* Dynamic Styles */
65+
body {
66+
font-family: ${styles.fontEN.fontFamily || styles.fontEN.name}, ${styles.fontCJK.fontFamily || styles.fontCJK.name};
67+
font-size: ${styles.fontSize}px;
68+
background-color: white;
69+
color: black;
70+
margin: ${styles.marginV}px ${styles.marginH}px;
71+
}
72+
73+
:not(.resume-header-item) > a {
74+
color: ${styles.themeColor};
75+
}
76+
77+
h1, h2, h3 {
78+
color: ${styles.themeColor};
79+
}
80+
81+
h1, h2 {
82+
border-bottom-color: ${styles.themeColor};
83+
}
84+
85+
p, li {
86+
line-height: ${styles.lineHeight.toFixed(2)};
87+
}
88+
89+
h2, h3 {
90+
line-height: ${(styles.lineHeight * 1.154).toFixed(2)};
91+
}
92+
93+
dl {
94+
line-height: ${(styles.lineHeight * 1.038).toFixed(2)};
95+
}
96+
97+
h2 {
98+
margin-top: ${styles.paragraphSpace}px;
99+
}
100+
`;
101+
102+
// Combine backbone CSS with dynamic CSS
103+
const fullCss = data.cssContent + dynamicCss;
104+
105+
// Create complete HTML document
106+
const htmlDocument = `<!DOCTYPE html>
107+
<html lang="en">
108+
<head>
109+
<meta charset="UTF-8">
110+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
111+
<title>${data.curResumeName}</title>
112+
<style>
113+
${fullCss}
114+
</style>
115+
</head>
116+
<body>
117+
<main id="vue-smart-pages-preview">
118+
${html}
119+
</main>
120+
</body>
121+
</html>`;
122+
123+
downloadFile(`${saveName.value}.html`, htmlDocument);
124+
};
52125
</script>

site/src/i18n/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ toolbar:
3939
import: Import Markdown
4040
export_pdf: Export PDF
4141
export_md: Export Markdown
42+
export_html: Export HTML
4243
correct_case:
4344
text: Correct Case
4445
desc: "Example: \"Github\"\"GitHub\" <br> Note: the words only including uppercase or lowercase (\"GITHUB\" or \"github\") will be left untouched"

site/src/i18n/sp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ toolbar:
3939
import: Importar Markdown
4040
export_pdf: Exportar PDF
4141
export_md: Exportar Markdown
42+
export_html: Exportar HTML
4243
correct_case:
4344
text: Corregir Mayusculas
4445
desc: "Ejemplo: \"Github\"\"GitHub\" <br> Nota: No se modificarán las palabras que sólo contengan mayúsculas o minúsculas (\"GITHUB\" or \"github\")"

site/src/i18n/zh-cn.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ toolbar:
3939
import: 导入 Markdown
4040
export_pdf: 导出为 PDF
4141
export_md: 导出为 Markdown
42+
export_html: 导出为 HTML
4243
correct_case:
4344
text: 专有名词大小写修正
4445
desc: "例如:\"Github\"\"GitHub\" <br> 注意:不会修正全为大写或小写字母的单词(如 \"GITHUB\"\"github\""

0 commit comments

Comments
 (0)