Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

editorjs-inline-image

kommitters3kMIT2.2.2

Unsplash inline images tool for editorjs

tool, image, server-less, editor.js, editorjs

readme

EditorJS Unsplash Inline Image Tool

stability-stable Coverage Status OpenSSF Best Practices OpenSSF Scorecard

Image tool for Editor.js that enables you to embed images from Unsplash, blobs, or URLs directly into your content.

Notes

Requires a proxy for the Unsplash API to avoid exposing the Unsplash Access Key on the client-side. See Proxy for Unsplash API for more information.

Built following the Unsplash API Guidelines.

Extends the functionality of simple-image.

Installation

You can install the tool via npm or load it from a CDN.

Install via NPM

Get the package

$ npm i --save-dev editorjs-inline-image

Include module at your application

import InlineImage from 'editorjs-inline-image';

Load from CDN

You can load a specific version of the package from jsDelivr CDN.

Require this script on a page with Editor.js.

<script src="https://cdn.jsdelivr.net/npm/editorjs-inline-image"></script>

Usage

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

const editor = EditorJS({
  tools: {
      image: {
        class: InlineImage,
        inlineToolbar: true,
        config: {
          embed: {
            display: true,
          },
          unsplash: {
            appName: 'your_app_name',
            apiUrl: 'https://your-proxy-api-url.com',
            maxResults: 30,
            imageParams: {
              q:85,
              w:1500,
            }
          }
        }
      }
  }
});

Config Params

Field Type Description
embed {display: boolean} You could display or not the embed tab, If you don't fill the embed config by default the value is set on true.
unsplash {appName: string, apiUrl: string, maxResults: Number, imageParams: Object} Config for Unsplash API. Contains 3 fields:

appName: Unsplash Application Name.

apiUrl: URL of the Proxy for Unsplash API.

maxResults: Max number of images per search (default 30).

imageParams: Additional configuration parameters for image quality and dimensions. See Dynamically resizable images for more information.

Tool's tunes

  1. Add border

  2. Stretch to full-width

  3. Add background

Output data

Field Type Description
url string Image's url
caption string Image's caption
withBorder boolean Add border to image
withBackground boolean Add background
stretched boolean Stretch image to screen's width
unsplash {author: string, profileLink: string} Unsplash image author information.

author: Author's name.

profileLink: Unsplash porfile link.

Image

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

Unsplash image

{
  "type": "image",
  "data": {
    "url": "https://images.unsplash.com/photo-xxxxxxxxxxxxxxxxx",
    "caption": "An image from Unsplash",
    "withBorder": false,
    "withBackground": true,
    "stretched": false,
    "unsplash": {
      "author": "John Doe",
      "profileLink": "https://unsplash.com/@john_doe_fake"
    }
  }
}

Development

Development mode

$ yarn build:dev

Production release

  1. Create a production bundle

    $ yarn build
  2. Commit dist/bundle.js

Run tests

$ yarn test

Code of conduct

We welcome everyone to contribute. Make sure you have read the CODE_OF_CONDUCT before.

Contributing

For information on how to contribute, please refer to our CONTRIBUTING guide.

Changelog

Features and bug fixes are listed in the CHANGELOG file.

License

This library is licensed under an MIT license. See LICENSE for details.

Acknowledgements

Made with 💙 by kommitters Open Source

changelog

Changelog

2.2.2 (11.09.2024)

  • Add allowed endpoints for scorecard.yml and changed the node version to 18 for publish.yml. See PR #154

2.2.1 (10.09.2024)

  • Update dependencies for compatibility and disable rules that are incompatible with ESLint v9. See PR #150

2.2.0 (06.09.2024)

  • Add the ability to modify the quality and dimensions of selected images by adding parameters to the image URL in the Unsplash element configuration, in accordance with the Unsplash API. See PR #147

2.1.1 (25.04.2024)

  • Add stale issues policy. See PR #140

2.1.0 (04.04.2024)

  • Update the security policy. SeePR #137
  • Update all dependencies. SeePR #134
  • Replace and remove intrinsic-scale. SeePR #134
  • Implement orientation feature to select query images between landscape, portrait, and squarish. See Issue #135

2.0.0 (26.02.2024)

1.2.4 (16.01.2023)

  • Update all dependencies.
  • Block egress traffic in GitHub Actions.
  • Add stability badge in README.

1.2.3 (28.12.2022)

  • Add Renovate as dependency update tool.
  • Keep read-only permissions in CI workflow.

1.2.2 (22.12.2022)

  • Apply security best practices hardening GitHub Actions.

1.2.1 (07.12.2022)

  • Bump minimatch from 3.0.4 to 3.1.2

1.2.0 (06.12.2022)

  • Bump loader-utils from 1.4.0 to 1.4.2
  • Bump decode-uri-component from 0.2.0 to 0.2.2
  • Implement feature: Image zoom when clicked

1.1.5 (28.10.2022)

  • Add Coverage Report with Coveralls

1.1.4 (12.09.2022)

  • Add OpenSSF BestPractices & Scorecard badges
  • Add CDN version documentation

1.1.3 (09.08.2022)

  • Add scorecards actions

1.1.2 (25.07.2022)

  • Add security policy to repository
  • Update packages with known security breaches

1.1.1 (15.07.2022)

  • Add workflow for automatic publishing in npm

1.1.0 (12.04.2022)

  • Change some classes names in order to avoid incompatibilities with some frameworks.

1.0.3 (29.03.2022)

  • Updated packages with known security breaches.

1.0.2 (21.02.2022)

  • Updated packages with known security breaches.

1.0.1 (19.01.2022)

  • Updated packages with known security breaches.
  • Update the css dependencies.

1.0.0 (09.11.2021)

  • Updated packages with known security breaches.

0.2.1 (29.09.2021)

  • Updated packages with known security breaches.

0.2.0 (09.09.2021)

  • Added a CI workflow with Github actions.
  • Updated packages with known security breaches.
  • Docs updated.

0.1.4 (28.06.2021)

  • Updated bundle file.
  • Bug fix.

0.1.3 (01.06.2021)

  • Config to disable the embed images tab was added.
  • Updated packages with known security breaches.

0.1.2 (29.04.2021)

  • Added support to read-only mode.
  • Updated packages with known security breaches.

0.1.1 (4.06.2020)

Bugfix

  • Only renders image credits if Unsplash data is valid.

0.1.0 (2.06.2020)

Initial release