MCPcopy Create free account
hub / github.com/027xiguapi/code-box / saveWord

Function saveWord

tools.ts:128–158  ·  view source on GitHub ↗
(dom: Element, filename?: string)

Source from the content-addressed store, hash-verified

126}
127
128export function saveWord(dom: Element, filename?: string) {
129 if (dom) {
130 const content = dom.innerHTML
131 const fullHtml = `<!DOCTYPE html>
132<html xmlns:o='urn:schemas-microsoft-com:office:office'
133 xmlns:w='urn:schemas-microsoft-com:office:word'
134 xmlns='http://www.w3.org/TR/REC-html40'>
135<head>
136<meta charset="utf-8">
137<title>${filename || "CodeBox-page"}</title>
138<style>
139 body { font-family: '宋体', SimSun, serif; font-size: 14pt; line-height: 1.8; padding: 20px; }
140 img { max-width: 100%; height: auto; }
141 h1, h2, h3, h4 { font-family: '黑体', SimHei, sans-serif; }
142 pre, code { font-family: 'Courier New', monospace; font-size: 12pt; }
143 table { border-collapse: collapse; width: 100%; }
144 td, th { border: 1px solid #ccc; padding: 6px; }
145 a { color: #576b95; }
146</style>
147</head>
148<body>
149${content}
150</body>
151</html>`
152 const blob = new Blob([fullHtml], {
153 type: "application/msword;charset=utf-8"
154 })
155 filename = filename || "CodeBox-page"
156 saveAs(blob, `${filename}-${dayjs().format("YYYY-MM-DD HH:mm:ss")}.doc`)
157 }
158}
159
160export function i18n(key: string) {
161 return chrome.i18n.getMessage(key)

Callers 15

downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85
downloadWordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected