kommitters / editorjs-inline-image

Unsplash inline images plugin for editorjs
https://www.npmjs.com/package/editorjs-inline-image
MIT License
97 stars 31 forks source link

Add tab for file upload #8

Closed tiotdev closed 3 years ago

tiotdev commented 3 years ago

I am currently using both https://github.com/editor-js/image and this tool since I want to offer both upload from file and Unsplash search. I would prefer to have image upload from file like in editorjs-image available as first tab in this tool.

moazam1 commented 3 years ago

+1

taurenshaman commented 3 years ago

I created a hard fork, which adds image upload based on flow.js and search on current server.

Default and Upload are both using defaultClient.js.

image

image

moazam1 commented 3 years ago

@taurenshaman brilliant. Can you add an option to hide tab(s)?

taurenshaman commented 3 years ago

@taurenshaman brilliant. Can you add an option to hide tab(s)?

I made some break changes to the code, so you can follow these 2 steps:

  1. add a property like supportEmbedUrl to the config:
    const editor = EditorJS({
    tools: {
      image: {
        class: InlineImage,
        inlineToolbar: true,
        config: {
          unsplash: {
            appName: 'your_app_name',
            clientId: 'your_client_id'
          },
          supportEmbedUrl: true
        }
      }
    }
    });
  2. update the render() function in controlPanel.js:
    // 2.1 tab
    if(this.config.supportEmbedUrl)
      tabWrapper.appendChild(embedUrlTab);
    // 2.2 panel
    if(this.config.supportEmbedUrl)
      wrapper.appendChild(embedUrlPanel);

effect: image

juanhurtado10 commented 3 years ago

Hey @tiotdev !! Thanks for reaching out. I've looked at your fork and looks great!. By now, this plugin is intended to be used just with inline images not uploaded ones. Best!!