Convert a Microsoft Word document to HTML in the browser.
import mammoth from "https://cdn.jsdelivr.net/npm/mammoth@1.9.0/+esm"
export const take = [
{
key: "buffer",
type: "file",
label: "Document",
accept: ".doc,.docx,application/msword",
read: "buffer",
},
{ type: "toggle", label: "Preview" },
]
export const make = async ([arrayBuffer, preview]) => {
let value
if (arrayBuffer) {
value = (await mammoth.convertToHtml({ arrayBuffer })).value
return [
{
...(preview ? { type: "html", height: 400 } : { type: "code" }),
value,
},
]
}
}