0.1.3 • Published 5 years ago
@illumini/editorjs-media v0.1.3
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
- Upload folder
dist
from repository - 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:
Field | Type | Description |
---|---|---|
onSelectMedia | function(done(media)) | Required: Function for invoking external media library and returning selected media |
buttonContent | string | Allows to override HTML content of «Browse Media Library» button |
Output data
This Tool returns data
with following format
Field | Type | Description |
---|---|---|
media | object | The 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"
}
}
}