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-mediaor
yarn add @illumini/editorjs-mediaInclude module at your application
import MediaBrowser from '@illumini/editorjs-media';Other methods
Manual downloading and connecting
- Upload folder
distfrom repository - Add
dist/bundle.jsfile 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"
}
}
}