import mammoth from "https://cdn.jsdelivr.net/npm/mammoth@1.9.0/+esm"
export const take = [
{
type: "file",
label: "Document",
accept: ".doc,.docx,application/msword",
read: "buffer",
},
{ type: "toggle", label: "Remove excess new lines", value: true },
]
export const make = async ([arrayBuffer, stripnl]) => {
let value
if (arrayBuffer) {
value = (await mammoth.extractRawText({ arrayBuffer })).value
if (stripnl) {
value = value
.replace(/\n +/g, "\n")
.replace(/\n\n\s*/g, "\n\n")
.trim()
}
return [{ type: "text", value }]
}
}