diff --git a/README.md b/README.md index 34cfbb0..27e3daf 100644 --- a/README.md +++ b/README.md @@ -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. @@ -18,7 +18,7 @@ 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) { @@ -26,15 +26,15 @@ const paster = new pasteFromWord({ }) }, // 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: '

paste-from-word

', text: 'paste-from-word'} }) }) diff --git a/package.json b/package.json index 0ae046e..74b5793 100644 --- a/package.json +++ b/package.json @@ -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", @@ -10,8 +10,11 @@ "keywords": [ "粘贴word文档", "Paste Microsoft Word", - "rich text", - "富文本编辑器" + "Paste Images from Word", + "rich text editor", + "富文本编辑器", + "粘贴 word 文档", + "粘贴 word 图片" ], "author": "heweifeng", "license": "MIT",