Code Monkey home page Code Monkey logo

hallo's Introduction

Hallo - contentEditable for jQuery UI

Hallo is a very simple in-place rich text editor for web pages. It uses jQuery UI and the HTML5 contentEditable functionality to edit web content.

The widget has been written as a simple and liberally licensed editor. It doesn't aim to replace popular editors like Aloha, but instead provide a smaller and less full-featured option. It is also intended to serve as a testbed for Aloha's jQuery UI migration, and so ideas and code from Hallo may flow back to the Aloha project.

Using the editor

You need jQuery and jQuery UI loaded. An easy way to do this is to use Google's JS service:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>

The editor toolbar is using jQuery UI theming, so you'll probably also want to grab a theme that fits your needs.

Then include Hallo itself:

<script src="hallo.js"></script>

Editor activation is easy:

jQuery('p').hallo();

You can also deactivate the editor:

jQuery('p').hallo({editable: false});

Hallo itself only makes the selected DOM elements editable and doesn't provide any formatting tools. Formatting is accomplished by loading plugins when initializing Hallo:

jQuery('.editable').hallo({
    plugins: {
        'halloformat': {}
    }
});

This example would enable the simple formatting plugin that provides functionality like bold and italic. You can include as many Hallo plugins as you want, and if necessary pass them options.

Please note that you need to load the plugin JavaScript files you want to use manually.

Hallo has got more options you set when instantiating. See the hallo.coffee file for further documentation.

Plugins

  • halloformat - Adds Bold, Italic, StrikeThrough and Underline support to the toolbar. (Enable/Disable with options: "formattings": {"bold": true, "italic": true, "strikeThough": true, "underline": false})
  • halloheadings - Adds support for H1, H2, H3. You can pass a headings option key "headers" with an array of header sizes (i.e. headers: [1,2,5,6])
  • hallojustify - Adds align left, center, right support
  • hallolists - Adds support for ordered and unordered lists (Pick with options: "lists": {"ordered": false, "unordered": true})
  • halloreundo - Adds support for undo and redo
  • hallolink - Adds support to add links to a selection (currently not working)

Licensing

Hallo is free software available under the MIT license.

Contributing

Hallo is written in CoffeeScript, a simple language that compiles into JavaScript. To generate the JavaScript code from Hallo sources, run:

$ coffee -c -o examples *.coffee

Hallo development is coordinated using Git. Just fork the Hallo repository on GitHub and send pull requests.

Writing plugins

Hallo plugins are written as regular jQuery UI widgets.

When Hallo is loaded it will also load all the enabled plugins for the element, and pass them two additional options:

  • editable: The main Hallo widget instance
  • toolbar: Toolbar jQuery object for that Hallo instance

A simplistic plugin would look like the following:

#    Formatting plugin for Hallo
#    (c) 2011 Henri Bergius, IKS Consortium
#    Hallo may be freely distributed under the MIT license
((jQuery) ->
    jQuery.widget "IKS.halloformat",
        bold: null

        options:
            editable: null
            toolbar: null

        _create: ->
            @bold = jQuery("<button>Bold</button>").button()
            @bold.click =>
                @options.editable.execute "bold"
            @options.toolbar.append @bold

        _init: ->

)(jQuery)

hallo's People

Contributors

beberlei avatar bergie avatar colinfrei avatar dbu avatar fabian avatar manuelstofer avatar

Stargazers

 avatar

Watchers

 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.