Coder Social home page Coder Social logo

jianfang-kso / tiny-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fvilers/tiny-editor

0.0 1.0 0.0 355 KB

A tiny HTML rich text editor written in vanilla JavaScript

Home Page: https://fvilers.github.io/tiny-editor

License: MIT License

HTML 13.22% JavaScript 81.68% CSS 5.10%

tiny-editor's Introduction

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 link tag in your HTML document <head> to load the Font Awesome icon set
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
  1. Add a data-tiny-editor attribute to the HTML element you want to transform into an editor

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.

tiny-editor's People

Contributors

fvilers avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.