Skip to content

Commit

Permalink
[fixed]update description and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
何伟峰 committed Feb 23, 2022
1 parent 38fc80b commit c99e305
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# paste from word
# paste from word for all rich text editors

粘贴 Word 文档内容到任何富文本编辑器, 完美支持多图文
粘贴 Word 文档内容到任何富文本编辑器, 完美支持多图文. 很多富文本编辑器不能直接粘贴从 word 文档复制的图片, 本插件可以解决这个问题. 适用于所有的富文本编辑器.

Paste from Microsoft Word without loosing any formatting for all rich text editor, support multi image and text.

Expand All @@ -18,23 +18,23 @@ npm 安装 `npm i paste-from-word --save`
```js
import pasteFromWord from 'paste-from-word'
const paster = new pasteFromWord({
// optional. Processing images function, the option blob is image blob, you can do something with the blob.And the option next is a function to put the image link to HTML string
// optional. Processing images function, the option blob is image blob, you can do something with the blob,like upload to server.And the option next is a function to put the image link to HTML string
// 可选项, 图片处理函数, 每一张图片都会调用此函数, 参数 blob 为图片的 blob 对象, 可以用于上传到服务器,获取到图片在服务器上的链接后, 调用 next 方法会自动回填到 HTML 字符串中
imageHandler: function (blob, next) {
upload(blob).then(function (response) {
next(response.imageUrl)
})
},
// optional. If this option set true, will ignore paste single image or file. Default is false
// 可选项. 是否忽略粘贴单张图片(剪贴板中只有一张图片)
// 可选项. 是否忽略粘贴单张图片(剪贴板中只有一张图片), 默认为 false
ignorePasteSingleFile: true, // true/false
})

const target = document.querySelector('div.target')
const target = document.querySelector('div.target-editor')

target.addEventListener('paste', pasteEvent => {
targetEditor.addEventListener('paste', pasteEvent => {
paster.parse(pasteEvent, function (res) {
// do something with HTML
// do something with paste HTML, like insert to editor
console.log(res) // {html: '<p>paste-from-word</p>', text: 'paste-from-word'}
})
})
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "paste-from-word",
"version": "1.0.4",
"description": "Paste from Microsoft Word without loosing any formatting for all rich text editor.粘贴Word文档内容到任何富文本编辑器",
"version": "1.0.5",
"description": "Paste from Microsoft Word without loosing any formatting for all rich text editor.粘贴Word文档内容到任何富文本编辑器,支持多图文",
"main": "dist/index.js",
"scripts": {
"build": "rollup --c",
Expand All @@ -10,8 +10,11 @@
"keywords": [
"粘贴word文档",
"Paste Microsoft Word",
"rich text",
"富文本编辑器"
"Paste Images from Word",
"rich text editor",
"富文本编辑器",
"粘贴 word 文档",
"粘贴 word 图片"
],
"author": "heweifeng",
"license": "MIT",
Expand Down

0 comments on commit c99e305

Please sign in to comment.