editorjs-youtube

Youtube block for Editor.js

Usage no npm install needed!

<script type="module">
  import editorjsYoutube from 'https://cdn.skypack.dev/editorjs-youtube';
</script>

README

YouTube tool

Provides Block Tool for embed YouTube videos for the Editor.js.

Installation

Install the package using NPM or Yarn

Via NPM

npm i --save editorjs-youtube

Via Yarn

yarn add editorjs-youtube

Import module at your application

import EditorJSYoutubeTool from "editorjs-youtube";

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

Require this script on a page with Editor.js.

<script src="https://cdn.jsdelivr.net/npm/editorjs-youtube"></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": "AwJwgRH1wpg",
        "url": "",
        "embedUrl": "https://www.youtube.com/embed/AwJwgRH1wpg"
    }
}