npm.io
1.1.4 • Published 3 years ago

transform-doc-to-html

Licence
MIT
Version
1.1.4
Deps
0
Size
535 kB
Vulns
0
Weekly
0

transform .docx file to html

Installation

npm install transform-doc-to-html
Usage

as react lib

import Doc2Html from 'transform-doc-to-html'

function App(){
  return (
    <Doc2Html
      onResult={html => doSomething(html)}
      imageUploadOptions={{}}
    >
      <div>上传doc</div>
    </Doc2Html>
  )
}

or

as function

import { getHtmlFromDocFile, extractRawText } from 'transform-doc-to-html'

const html = await getHtmlFromDocFile(file, imageUploadOptions)
const text = await extractRawText(file)
options
  • onResult: return html,required
  • imageUploadOptions
    • api: upload interface
    • code: 'file' | 'image', interface param code
    • processResult: uploadResult => imageUrl

Keywords