0.0.5 • Published 3 years ago

editorjs-youtube-tool v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

YouTube tool

Provides Block Tool for embed YouTube videos for the Editor.js. This is just an example! Please use official Embed Tool instead.

Installation

Install the package using NPM or Yarn

Via NPM

npm i --save editorjs-youtube-tool

Via Yarn

yarn add editorjs-youtube-tool

Import module at your application

import EditorJSYoutubeTool from "editorjs-youtube-tool";

Download to your project's source dir

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

Load from CDN

You can load EditorJSYoutubeTool from jsDelivr CDN:

https://cdn.jsdelivr.net/npm/editorjs-youtube-tool

Require this script on a page with Editor.js.

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

Usage

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

const editor = EditorJS({
  ...
  
  tools: {
    ...
    youtube: EditorJSYoutubeTool,
  }
  
  ...
});

Output data

YoutubeTool block returns code:

{
    "type" : "youtube",
    "data" : {
        "id": "LOPHWxybSCA",
        "url": "https://www.youtube.com/watch?v=LOPHWxybSCA&t=2844s&ab_channel=AlexandrKupnyi",
        "embedUrl": "https://www.youtube.com/embed/LOPHWxybSCA"
    }
}