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

tiny-editor

v0.4.0

Published

A tiny HTML rich text editor written in vanilla JavaScript

Downloads

1,221

Readme

tiny-editor

A tiny HTML rich text editor written in vanilla JavaScript

Goal

Create a less than 5 Kb (compressed) library that enables a HTML element to be used as a rich text editor in plain old vanilla JavaScript.

Support

If you use and like this library, feel free to support my Open Source projects.

donate

How to install

npm install tiny-editor

or load the bundle file directly at the end of your HTML document.

<script src="https://unpkg.com/tiny-editor/dist/bundle.js"></script>

How to use

  1. Reference the editor library in your HTML document
  2. Add a data-tiny-editor attribute to the HTML element you want to transform into an editor

How to dynamically create an editor

Use the exported function window.__tinyEditor.transformToEditor() which take as the first argument the DOM element (usually a <div>) that you want to transform to an editor. Refer to the /public/index.html for an example.

How to extract the formatted text

Listen for the input event on the editor HTML element.

document
  .querySelectorAll('[data-tiny-editor]')
  .forEach(editor =>
    editor.addEventListener('input', e => console.log(e.target.innerHTML)
  )
);

How to customize

There are various options that can be used to customize how the Tiny Editor will be rendered. By default, every options are enabled. You can disable an option using data attributes.

For example, you can remove the bold format button using the following attribute:

<div data-tiny-editor data-bold="no"></div>

Options

  • data-formatblock="no": remove the styles drop down list
  • data-bold="no": remove the bold button
  • data-italic="no": : remove the italic button
  • data-underline="no": remove the underline button
  • data-fontname="no": remove the font drop down list
  • data-forecolor="no": : remove the text color button
  • data-justifyleft="no": remove the left align button
  • data-justifycenter="no": remove the center align button
  • data-justifyright="no": remove the right align button
  • data-insertorderedlist="no": remove the numbered list button
  • data-insertunorderedlist="no": remove the bulleted list button
  • data-outdent="no": remove the decrease indent button
  • data-indent="no": remove the increase indent button
  • data-remove-format="no": remove the clear formatting button

Supported browsers

Modern browser (Chrome, Firefox, Edge,...) are supported. Tiny Editor doesn't work on Internet Explorer.