npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paste-from-word

v1.0.5

Published

Paste from Microsoft Word without loosing any formatting for all rich text editor.粘贴Word文档内容到任何富文本编辑器,支持多图文

Downloads

64

Readme

paste from word for all rich text editors

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

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

浏览器兼容性

兼容常见的 PC 浏览器:Chrome,Firefox,Edge,QQ 浏览器,IE11 。

🚧 MacOS 的浏览器不支持粘贴 word 文档内的图片。 🚧 MacOS browser Not Support paste image from Microsoft Word

基本使用

npm 安装 npm i paste-from-word --save

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,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-editor')

targetEditor.addEventListener('paste', pasteEvent => {
    paster.parse(pasteEvent, function (res) {
        // do something with paste HTML, like insert to editor
        console.log(res) // {html: '<p>paste-from-word</p>', text: 'paste-from-word'}
    })
})