0.1.3 • Published 5 years ago

@illumini/editorjs-media v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

npm.io

Media Browser Tool

Media Browser Block for the Editor.js.

Features

  • Allows adding custom media (images, videos and files) from an external media library

Installation

Install via NPM/Yarn

Get the package

npm i @illumini/editorjs-media

or

yarn add @illumini/editorjs-media

Include module at your application

import MediaBrowser from '@illumini/editorjs-media';

Other methods

Manual downloading and connecting

  1. Upload folder dist from repository
  2. Add dist/bundle.js file to your page.

Usage

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

import MediaBrowser from '@illumini/editorjs-media';

var editor = EditorJS({
  ...

  tools: {
    ...
    media: {
      class: MediaBrowser,
      config: {
        onSelectMedia: done => {
          const mediaUrl = openMediaLibrary();
          done(mediaUrl);
        },
      },
    },
  },
  ...
});

Config Params

Image Tool supports these configuration parameters:

FieldTypeDescription
onSelectMediafunction(done(media))Required: Function for invoking external media library and returning selected media
buttonContentstringAllows to override HTML content of «Browse Media Library» button

Output data

This Tool returns data with following format

FieldTypeDescription
mediaobjectThe selected media. Always contain the url property
{
  "type": "media",
  "data": {
    "media": {
      "url": "https://www.tesla.com/tesla_theme/assets/img/_vehicle_redesign/roadster_and_semi/roadster/hero.jpg"
    }
  }
}
0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago