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

m-embed

v1.0.5

Published

An embed extension for MediumEditor using Embedly's API (http://embed.ly).

Downloads

9

Readme

M-Embed for MediumEditor

M-Embed is a MediumEditor extension to embed URL previews with Embedly's API in your contenteditable editor. Once embedded, you can choose between the multiple media (images, iframes) returned for the URL. M-Embed has been written using vanilla JavaScript, no additional frameworks are required.

Demo

Here is a demo (using predefined data—without making a request to Embedly, which would require an API key. Embedly has free and paid plans to access their API.)

Installation

Via npm:
Run in your console: npm install m-embed

Usage

Upon instantiation of the editor, instantiate the extension in the extensions property, reference the button in the toolbar > buttons array.

var editor = new MediumEditor('.editable', {
    mEmbed : {
        // options for m-embed 
    },
    toolbar: {
      buttons: [
          // other toolbar buttons
          'mEmbed'
      ]
    },
    extensions: {
        // other MediumEditor extensions
        mEmbed: new MEmbed()
    }
});

Options

The following options, and their defaults, are available to customize M-Embed. The options object is passed as a property named mEmbed when you instantiate MediumEditor.

  • key Your Embedly API key. Default: null
  • fakeData For testing purposes, the API key requirement will be bypassed. Default: null
  • endpoint API endpoint (see Embedly). Default: 'extract'
  • secure http(s) (see Embedly). Default: undefined
  • query (see Embedly). Default: {}
  • urlRe Additional regular expression to test the URL against, just before the XHR call. Default: undefined
  • allowMultiple Allow multiple embeds per editor. Default: false
  • displayErrors Display errors in the editor (they are also emitted through an event). Default: true
  • linkTarget The embed link target. Default: '_blank'
  • hideToolbarAfter Hide the toolbar after embedding. Default: true
  • deselectAfter Deselect the url after embedding. Default: true
  • thumbnailSize Images smaller than 300 will trigger a 'thumbnail' class on the main element. Default: 300
  • thumbnailMini Size at which to add class 'mini' on the image div. Default: 100

Events

Triggered:

  • m-embed:error Request validation, xhr & general errors — { msg, error }
  • m-embed:success Successful request — { response }
  • m-embed:progress Request progress — { msg: percentage }
  • m-embed:media Included media (picture, video), fired on render and on user choice — { media }
  • m-embed:no-media User has removed media from preview
  • m-embed:removed Embed has been removed entirely
  • m-embed:cleanup Remove all non content clutter — pass in the editor element
  • m-embed:revive Reapply the ui for an existing preview — pass in the editor element
  • m-embed:swap Replace the media with another image — pass in { mime: '', url: '' } and the editor element