Skip to content

Commit

Permalink
fix: css variable replace
Browse files Browse the repository at this point in the history
  • Loading branch information
dribble-njr committed Dec 11, 2024
1 parent 2ae75ab commit a094aed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export const useStore = defineStore(`store`, () => {

// 导出编辑器内容为 HTML,并且下载到本地
const exportEditorContent2HTML = () => {
exportHTML()
exportHTML(primaryColor.value)
document.querySelector(`#output`)!.innerHTML = output.value
}

Expand Down
8 changes: 7 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,16 @@ export function downloadMD(doc: string) {
/**
* 导出 HTML 生成内容
*/
export function exportHTML() {
export function exportHTML(primaryColor: string) {
const element = document.querySelector(`#output`)!

setStyles(element)

const htmlStr = element.innerHTML
.replaceAll(`var(--el-text-color-regular)`, `#3f3f3f`)
.replaceAll(`var(--blockquote-background)`, `#f7f7f7`)
.replaceAll(`var(--md-primary-color)`, primaryColor)
.replaceAll(/--md-primary-color:.+?;/g, ``)

const downLink = document.createElement(`a`)

Expand Down

0 comments on commit a094aed

Please sign in to comment.