npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grapesjs-video-embed-manager

v1.0.4

Published

A wrapper that turns the grapesjs video component into a dynamic experience, opening a modal similar to the GrapesJS Asset Manager. This plugin has been optimized to work with Youtube, Vimeo, and a local video server.

Downloads

252

Readme

Video Embed Manager

DEMO

HTML

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/grapesjs-video-embed-manager"></script>

<div id="gjs"></div>

JS

const editor = grapesjs.init({
	container: '#gjs',
  height: '100%',
  storageManager: false,
  plugins: ['grapesjs-video-embed-manager'],
});

Summary

  • Plugin name: grapesjs-video-embed-manager
  • A wrapper that turns the grapesjs video component into a dynamic experience, opening a modal similar to the GrapesJS Asset Manager. This plugin has been optimized to work with Youtube, Vimeo, and a local video server. No loading of components or blocks necessary.

Options

*See src/video_media_manager/config/config.js for detailed information about each option.

| Option | Description | Default | |-|-|- | resources | The resources to query to get your videos. Valid options are youtube, vimeo, and local. | [] | | youtubeLoadUrl | The server url used to manage getting videos. | null | | youtubeLoadCallback | Only for youtube since there are public videos. This is a custom callback that can be used to obtain the vidoes instead. | null | | youtubeBeforeLoad | ADVANCED: If you need to alter the data before it is loaded. This is best used if you have little control over how the data is returned. | null | | youtubeBeforeInsert | ADVANCED: If you want to alter the video data before it is inserted. This will probably only be used if you have a custom video component. | null | | youtubeData | This is a pseudo option mainly used for demo purposes. Used to manage what videos are currently showing on page. | null | | youtubeHeaders | Any headers that need to be passed in your request. | {} | | youtubeParams | Any parameters that need to be passed in your request. | {} | | vimeoLoadUrl | See youtube description. Same value used for Vimeo. | null | | vimeoBeforeLoad | See youtube description. Same value used for Vimeo. | null | | vimeoBeforeInsert | See youtube description. Same value used for Vimeo. | null | | vimeoData | See youtube description. Same value used for Vimeo. | null | | vimeoHeaders | See youtube description. Same value used for Vimeo. | {} | | vimeoParams | See youtube description. Same value used for Vimeo. | {} | | localLoadUrl | See youtube description. Same value used for your local videos. | null | | localBeforeLoad | See youtube description. Same value used for your local videos. | null | | localBeforeInsert | See youtube description. Same value used for your local videos. | null | | localData | See youtube description. Same value used for your local videos. | null | | localHeaders | See youtube description. Same value used for your local videos. | {} | | localParams | See youtube description. Same value used for your local videos. | {} | | preloader | image src string used for the loading preloader. If not provided, the manager will just say "loading".| null | | per_page | The amount of videos to show in manager view. Will be used in your server queries. | 12 |

Query Values for local development

| Option | Description | |-|- | per_page | This will tell your server how many videos to return. | | page | This will tell your server which page number you are requesting | | page_token | Used only for youtube, but I suppose you could emulate their style and use page tokens instead of page numbers |

What's with the Error Codes?

If the Video Manager errors due to improper setup or other factor, sometimes a message accompanied by an HTTP Status Code will appear. Technically, some of the errors are client side and not from a server, however, there aren't good status codes for client side (unless I am completely in the dark). Because of this, a somewhat descriptive HTTP Status Code will be used alongside the error so you can make an educated guess as to why something has happened.

Download

  • CDN
    • https://unpkg.com/grapesjs-video-embed-manager
  • NPM
    • npm i grapesjs-video-embed-manager
  • GIT
    • git clone https://github.com/booellean/grapesjs-video-embed-manager.git

Usage

Directly in the browser

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="path/to/grapesjs-video-embed-manager.min.js"></script>

<div id="gjs"></div>

<script type="text/javascript">
  var editor = grapesjs.init({
      container: '#gjs',
      // ...
      plugins: ['grapesjs-video-embed-manager'],
      pluginsOpts: {
        'grapesjs-video-embed-manager': { 
          preloader : 'https://gifimage.net/wp-content/uploads/2018/04/loading-icon-gif-6.gif',
          resources: [ 'youtube', 'vimeo', 'local' ],
          per_page: 5,
          youtubeLoadCallback: (data) => data,
          youtubeLoadUrl: '/fake/callback'
      }
  });
</script>

Modern javascript

import grapesjs from 'grapesjs';
import plugin from 'grapesjs-video-embed-manager';
import 'grapesjs/dist/css/grapes.min.css';

const editor = grapesjs.init({
  container : '#gjs',
  // ...
  plugins: [grapesjs-video-embed-manager],
  pluginsOpts: {
    'grapesjs-video-embed-manager': { /* options */ }
  }
  // or
  plugins: [
    editor => ['grapesjs-video-embed-manager'](editor, { /* options */ }),
  ],
});

Development

Clone the repository

$ git clone https://github.com/booellean/grapesjs-video-embed-manager.git
$ cd grapesjs-video-embed-manager

Install dependencies

$ npm i

Start the dev server

$ npm start

Build the source

$ npm run build

License

MIT

Important Note

This plugin adds to the dblclick event of the video component. This was decided by the dev so that the end user wouldn't have to load a custom component that is exactly the same as the video componenet, but with this one feature. It has been tested to not override any future dblcick events if the video component is ever updated.