Giter VIP home page Giter VIP logo

bmpi-dev / vscode-extension-mardown-image-paste Goto Github PK

View Code? Open in Web Editor NEW

This project forked from njleonzhang/vscode-extension-mardown-image-paste

10.0 2.0 2.0 95 KB

read the image from system clipborad, optimize the size, upload to CDN, and return you the CDN link. https://marketplace.visualstudio.com/items?itemName=njLeonZhang.markdown-image-paste

Home Page: https://www.bmpi.dev/self/note-system/

TypeScript 100.00%

vscode-extension-mardown-image-paste's Introduction

vscode-extension-mardown-image-paste (currently macos only)

A command to read the image from system clipborad, optimize the size, upload to CDN, and return you the CDN link. Support jpg, png, pdf....

Chinese blog introducing this extension: http://www.njleonzhang.com/2018/08/14/vs-code-paste-image.html

How?

vscode-plugin-deep

  • The extension spawn a electron process for read image in clipborad via electron api clipboard.readImage.
  • extension process communicate with electron process via node-ipc.
  • send the image to tinyPng for size optimization.
  • send the image to CDN for hosting

Installation

  • Install this extension. (search by name markdown image paste in vscode extension store)

  • Install the electron ipc server app.

      npm install -g electron-image-ipc-server
    

    You can start the electron ipc server manually by command eiis

Supported CDN Comparison

CDN Advantage Disadvantage
qiniu totally 10G free storage; monthly 1 million times free viewing; fast net access globally; big and stable company in China need filing domain approved by China goverment for accessibility ๐Ÿ˜‚
github based on github, little limitation if you follow the terms of service and github pages limits; great and stable company access is slow in China
cloudinary totally 10G free storage for at most 300K items, 20 GB free monthly net viewing bandwith, fast net access globally a small and unstable company? (not sure)
sm.ms No limitation, fast access in China no account, and you can not manage your picture, private projects
s3 Pay only for what you use. There is no minimum fee, fast access in global need AWS account

This extension is made originally for writing my personal techblog, which means the storage and network access cost to the CDN should be small. You should not use this extension to upload pitures with mass access to github, which may exceed github pages limits.

Extension Settings

Setting type default desc
markdownPasteImage.cdnType string "github" cdn type, currently support qiniu, github, cloudinary, sm
markdownPasteImage.tinyPngKey string '' the tiny png developer key, refer to the doc, if not provided, the optimization is skipped
markdownPasteImage.qiniuBucket string "" qiniu cdn's bucket name
markdownPasteImage.qiniuAK string "" qiniu cdn's access key
markdownPasteImage.qiniuSK string "" qiniu cdn's security key
markdownPasteImage.qiniuPreUrl string "" qiniu cdn's pre-url
markdownPasteImage.githubAccessToken string "" the github access token, created in github token management page with all privileges of repo scope
markdownPasteImage.githubRepo string "" github repository to store your images, example: njleonzhang/image-bed;
Formart: [username]/[repo name], for example: njleonzhang/image-bed
markdownPasteImage.githubAssetFolder string "" asset folder of your image bed github repository
markdownPasteImage.proxy string "" proxy for github api, for exmaple: http://127.0.0.1:1087
markdownPasteImage.githubTimeOut number 10000 github api is slow in china, here you can set timeout according to you network. 10s as default
markdownPasteImage.cloudinaryName string "" cloud name of cloudinary
markdownPasteImage.cloudinaryApiKey string "" api key of cloudinary
markdownPasteImage.cloudinarySecret string "" api secret of cloudinary
markdownPasteImage.cloudinaryFolder string "" folder of cloudinary you want to put your image in
markdownPasteImage.s3Bucket string "" s3 bucket name, like "com.xxx.xxx"
markdownPasteImage.s3PreUrl string "" s3 domain name, like "img.xxx.xxx"

when you select s3, you must config s3 Credentials in your computer, follow this link step: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-nodejs.html

if cdn is not configured correctly or the editing file is not a markdown file, the picture will be paste to current folder of the editing file.

if you use github as cdn in China, I suggest you config a proxy.

command name desc
extension.markdownPasteImage Paste Image paste the clipbord image to cdn
extension.markdownPasteImage.reInit Paste Image: Reinit restart and reconnect to electron app which act as ipc server

PR welcomed

  • support more CDN, such as Amozon S3 and Azure storage, refer to current code

Development

Clone the porject, and open it in vscode. press F5 to start debug mode after npm install the dependency. At last, run npm run package to package a extension vsix file, and install it to your vscode for test.

Limitations

  1. need to install a extra node module, electron-image-ipc-server. if we bundle the electron in the extension, the extension size will be more than 70M. electron-image-ipc-server is started as a long live electron process by the extension.
  2. can not support gif due to the limitation of electron api

vscode-extension-mardown-image-paste's People

Contributors

madawei2699 avatar njleonzhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.