1.0.9 • Published 2 years ago

@7polo/editorjs-image v1.0.9

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Image

Image Tool for Editor.js 2.0

Feature

  • Embed Url ✌️
  • Unsplash ✌️
  • upload ✌️
  • extend
  • image viewer ✌️ (use by viewerjs)

tab

embed url

npm.io

upsplash

npm.io

upload

npm.io

extend

just add any tab you wanted


viewer

just double click the image npm.io


Usage

Add a new Tool to the tools property of the Editor.js initial config.

  1. npm
npm i @7polo/editorjs-image
  1. init & config
var editor = EditorJS({
  ...
  tools: {
    ...
    image: {
        class: Image,
        config: {
            unsplash: {
                search: ()=> {
                    return new Promise(function(resolve){
                        // resp from api : https://api.unsplash.com/search/photos 
                        resolve({});
                    })
                }
            },
            upload: {
                doUplaod: ()=> {
                    return new Promise(function(resolve){
                        resolve({url});
                    })
                }
            }
        }
    }
  }
  ...
});

Config Params

FieldTypeDescription
unsplash.searchfunctionresponse from unsplash https://api.unsplash.com/search/photos

unsplash.search like this

export const searchImages = (query) => {
    console.log("search" + query)

    return axios.get(`https://api.unsplash.com/search/photos`, {
        headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Credentials': false,
            'Content-Type':'application/x-www-form-urlencoded'
        },
        params: {
            client_id: 'your client_id',
            query
        }
    })
}

Output data

This Tool returns code.

{
  "type" : "image",
  "data" : {
    "url" : "https://www.example.com/image.jpg",
    "withBorder" : false,
    "withBackground" : false,
    "stretched" : true
  }
}
1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago