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

simplemirror

v1.0.17

Published

A simple and easy to use WYSIWYWG editor based on ProseMirror

Downloads

26

Readme

SimpleMirror

A simple and easy to use WYSIWYWG editor based on ProseMirror

How to use

Integrate into your project

  • dist/SimpleMirror.cjs.js A CommonJS bundle, suitable for use in Node.js, that requires the external dependency.
  • dist/SimpleMirror.esm.js an ES module bundle, suitable for use in other people's libraries and applications, that imports the external dependency.
  • dist/SimpleMirror.umd.js a UMD build, suitable for use in any environment (including the browser, as a <script> tag), that includes the external dependency.
  • dist/SimpleMirror.css Essential CSS for the editor

Then create a new editor instance. That's it!

Example 1: http://simplemirror.now.sh

new SimpleMirror({
  selector: '#editor',
  value: 'Please change this text',
  onChange: function(value) {
    console.log(value)
  }
})

Configuration

selector

The CSS selector where the editor should be inject to

value

The content to show in the editor after initialization. It could be plain text or HTML

onChange

The callback function to watch if editor's content has been changed

config

Defined commands to be used. If ignored, the editor will show all default commands using Fontawesome icons. You can specify CSS classes for the menu items and/or keyboard shortcuts and/or input rules if you want.

  • Customizable commands: ["undo", "redo", "bold", "italic", "strikethrough", "h1", "h2", "h3", "h4", "h5", "h6", "orderedList", "unorderedList", "indent", "outdent", "quote", "code", "insertImage"].
  • Key names may be strings like "Shift-Ctrl-Enter"—a key identifier prefixed with zero or more modifiers. Key identifiers are based on the strings that can appear in KeyEvent.key. Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held). You may use "Space" as an alias for the " " name. You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms.
  • For insertImage command, you can pass an option for cloudinary integration
    insertImage: {
      options: {
        cloudinary: {
          cloudName: 'yourCloudName',
          uploadPreset: 'yourUploadPreset', // support unsigned preset only
          googleApiKey: 'yourGoogleAPIKey' // for image search via google
        }
      }
    }
    otherwise, the editor will prompt for an image URL

Example 2: http://simplemirror.now.sh/custom.html

new SimpleMirror({
  selector: '#editor',
  value: 'Please change this text',
  config: {
    h1: {
      text: 'H1',
      inputRule: /^#\s/
    },
    bold: {
      className: 'material-icons',
      text: 'format_bold',
      shortcuts: ['Mod-b']
    },
    italic: {
      className: 'material-icons',
      text: 'format_italic',
      shortcuts: ['Mod-i']
    },
    undo: {
      shortcuts: ['Mod-z']
    }
  },
  onChange: function(value) {
    console.log(value)
  }
})

License

MIT.