Giter Site home page Giter Site logo

grande.js's Introduction

Build Status

grande.js

This is a small Javascript library that implements features from Medium's editing experience. Take a look here.

image

How to get started

Installation

Bower is the preferred way to install grande.js, it is available as grande in the Bower package repository.

Simply bower install grande

Usage

See the index.html in this repository for a functional example using the library.

To get up and running simply...

  1. Include an <article> with contenteditable
  2. Include the grande.min.js file (in dist/ directory) at the bottom of your <body>
  3. Initialize a new editor on the article tags with new Grande(document.querySelectorAll("article"))
  4. You are set!

Included files

There are two CSS files that come with the included demo:

  • editor.css: this file provides the style for the contenteditable elements on the page
  • menu.css: this file provides the toolbar styling to appear as it does below

Options

The Grande function currently accepts two parameters: bindableNodes and an options list.

The calling code can pass in a NodeList as the first parameter that will bind to these elements and enable contentEditable on them, if nothing is passed in it defaults to elements that match the selector .g-body article.

The second parameter is an options object that accepts the following keys:

  • mode: defaults to rich which enable users to format the text and enter multi-line function. If set to inline, it'll only accepts single line input and no formatting. If set to pratial it'll allow multi-line editing without rich editing.

  • placeholder: if set, this will be the placeholder value of the element(s), when the user focus on the element the placeholder will be deleted and put back when blurred while the field is empty.

  • animate: if true, this will trigger the CSS animations (defaults to true). Useful to turn to false if subpixel-antialised is needed in Safari.

  • imagesFromUrls: if set to true, it'll replace images URLs with s tags in "rich" mode.

image

The following tag stylings are available: <b>, <i>, <h1>, <h2>, <blockquote>, <a>, <ol>, <ul>, <hr>

Notes

This is a clone of Grande, but we choose to take a different approach of usage that is similar to Medium.js. Some of the grande methods were binded on document which didn't allow much configuration to be set for different elements on the same page. We plan to keep this in sync with the original mduvall/grande.js. Feel free to use this in any of your projects.

Roadmap

  • Images (figure)
  • Shortcuts for formatting (Cmd+b, Cmd+i...)
  • More Code Cleanup.
  • Better unit testing.

grande.js's People

Contributors

mduvall avatar mkhatib avatar zzimbler avatar dylan-baskind avatar rubypirate avatar iromli avatar juzerali avatar mhitza avatar rashahussein avatar

Stargazers

Abderrahmane Moussaoui avatar Edgenius avatar  avatar

Watchers

 avatar John Hatton avatar James Cloos avatar  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.