Giter Site home page Giter Site logo

forger.js's Introduction

Forger.js

forge:

  • create (something) strong, enduring, or successful.
  • move forward gradually or steadily.

A lightweight WYSIWYG editor.

Demo

You can play with Forger.js here.

Please bare in mind that there are a few things to fix. I've tried to be super transparent with these issues, they will either be in the TODO.md file or denoted by // TODO comments in the code. I'm working as hard as I can to get these checked off when I can.

Dependencies

Forger does make use of reMarked.js and MicroEvent.js, these are packaged in the /dist versions for you already. Forger doesn't have a dependency on jQuery, although you are free to make use of the optional jQuery wrapper if you want.

Installation

Use either the minified version of Forger.js, or the unminified version, linked within the /dist directory. I will be adding Forger.js to Bower once it's at a nice stable point.

How to use

Simply make a new Forger instance passing through the element you'd like to have contenteditable functionality, and an optional set of options if you wish.

new Forger(document.querySelector('#test'), options);

Styling (CSS)

I've made the assumption that most people will want to style their own Forger instances. However, there is 'default' Forger.js CSS within forger.css. At the moment this is mixed in with CSS I'm using on the demo page, I'll be looking to split this out soon so people can use it properly. I'll also be denoting what is required for Forger.js to work properly, and which styles are totally up to you to implement. That way you can just scrap the optional pieces if you wish. Feel free to use the default look though.

Events

There are a number of Forger events you can hook in to. These are:

TODO: Documentation is coming on events

Options

var options = {
    formatting: 'Markdown',

    mode: 'regular', // Regular / inline
     
    placeholder: 'Content here', // Text to be inserted when element is empty

    hooliganismDisabled: true, // Should users be stopped from just sitting hitting enter repeatedly?

    positioning: null, // Info coming soon on this
    
    // Which choices of formatting should be used
    painters: {
        Link: {
            className: 'fa fa-link',
            enabled: true,
        },

        Bold: {
            className: 'fa fa-bold',
            enabled: true
        },

        Italic: {
            className: 'fa fa-italic',
            enabled: true
        },

        UnorderedList: {
            className: 'fa fa-list-ul',
            enabled: true
        },

        OrderedList: {
            className: 'fa fa-list-ol',
            enabled: true
        },

        Headings: {
            className: 'fa fa-font headings',
            enabled: true, 
            levels: [1, 2, 3] // H1, H2, H3 etc
        },

        Blockquote: {
            className: 'fa fa-quote-right',
            enabled: true
        }
    },

    shortcutsEnabled: true,
    
    shortcuts: [
        {
            key: 'ctrl + b',
            command: 'Bold'
        },

        {
            key: 'ctrl + i',
            command: 'Italic'
        },

        {
            key: 'ctrl + q',
            command: 'Blockquote'
        },

        {
            key: 'ctrl + h',
            command: 'H1'
        },

        {
            key: 'ctrl + s',
            command: 'H2'
        }
    ]
};

jQuery wrapper

This is just a convenience wrapper, you don't have to use it.

$('#test').Forger(options)

Public Methods

var instance = new Forger(document.querySelector('#test'), options);

.HTML()

Returns the editor's HTML content

instance.HTML();

.markdown()

Returns the editor's content in Markdown format

instance.markdown();

Extend with your own 'Painters'

TODO: Docs for this coming soon

Plugins

TODO: Docs for this coming soon

Credits

  • Browserify for CommonJS module functionality
  • HTML to Markdown parsing is provided by reMarked.js library.
  • Lightweight event emitter capabilities are provided by MicroEvent.js.
  • Some CSS animations are provided by Animate.css.
  • classList functionality is provided to older browsers thanks to a shim from Eli Grey, ClassList.js.

Alternatives

You might not like Forger.js, and that's okay. There are a lot of WYSIWYG alternatives, if Forger isn't what you're looking for, one of these might be:

Paid for

Open source

Monolithic

License

The MIT License (MIT)

Copyright (c) 2014, Kerry Gallagher, Bear & Owl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

forger.js's People

Contributors

kerry350 avatar

Stargazers

Jon B avatar Michael Schuett avatar Olivier Meunier avatar Sam Beckham avatar Jason Judge avatar  avatar Marc Qualie avatar  avatar

Watchers

Philip Poots avatar James Cloos avatar Sam Beckham avatar  avatar

Forkers

saintclair

forger.js's Issues

Support for strikethrough for "deleted" text?

I'm looking at using forger.js to help me fix the huge accessibility issue of auto-craptioning* on YouTube for people who are Deaf or hard of hearing.

My plan at this initial stage is to enable people to fix the auto-craptioning, which I will place in separate time-coded segments or snippets of text, and I need to be able to keep track of text which is deleted.

Cheers for now, Mike Lockrey

  • That's not a typo ;)

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.