Git Product home page Git Product logo

wysi's Introduction

Wysi

Wysi in light mode

A lightweight and simple WYSIWYG editor written in vanilla ES6 with no dependencies.

View demo

This is an early release. Use in production is NOT YET RECOMMENDED.

Features

  • Lightweight (around 10KB minified and gzipped)
  • Zero dependencies
  • Very easy to use
  • Customizable
  • Dark mode support
  • Auto grow editor instances to fit content
  • Filters content when pasting
  • Works on all modern browsers

Getting Started

Basic usage

Download the latest version, and add the script and style to your page:

<link rel="stylesheet" href="wysi.min.css"/>
<script src="wysi.min.js"></script>

Or include from a CDN (not recommended in production):

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mdbassit/Wysi@latest/dist/wysi.min.css"/>
<script src="https://cdn.jsdelivr.net/gh/mdbassit/Wysi@latest/dist/wysi.min.js"></script>

Then create an editor instance using a CSS selector pointing to one or more textarea elements:

<textarea id="demo1"></textarea>
<script>
Wysi({
  el: '#demo1'
})
</script>

This will convert the textarea element to a WYSIWYG editor with the default settings.

Customizing the editor

The editor can be configured by calling Wysi() and passing an options object to it. Here is a list of all the available options:

Wysi({
  
  // A selector pointing to one or more textarea elements to convert into WYSIWYG editors.
  // This can also accept a Node, a NodeList, an HTMLCollection or an array of DOM elements.
  el: '.richtext',

  // Enable dark mode. This only affects the toolbar, not the content area.
  darkMode: false,

  // The height of the editable region.
  height: 200,

  // Grow the editor instance to fit its content automatically.
  // The height option above will serve as the minimum height.
  autoGrow: false,
  
  // Automatically hide the toolbar when the editable region is not focused.
  autoHide: false,

  // A function that is called whenever the content of the editor instance changes.
  // The  new content is passed to the function as an argument.
  onChange: (content) => console.log(content)
});

Building from source

Clone the git repo:

git clone [email protected]:mdbassit/Wysi.git

Enter the Wysi directory and install the development dependencies:

cd Wysi && npm install

Run the build script:

npm run build

The built version will be in the dist directory in both minified and full copies.

Alternatively, you can start a gulp watch task to automatically build when the source files are modified:

npm run watch

Contributing

If you find a bug or would like to implement a missing feature, please create an issue first before submitting a pull request (PR).

When submitting a PR, please do not include the changes to the dist directory in your commits.

License

Copyright (c) 2023 Momo Bassit.
Wysi is licensed under the MIT license.

wysi's People

Contributors

mdbassit 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.