• This repository has been archived on 23/Jan/2023
  • Stars
    star
    2,435
  • Rank 18,894 (Top 0.4 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple rich text editor (contentEditable) for jQuery UI

Hallo - contentEditable for jQuery UI Build Status Greenkeeper badge

Hallo Editor logo

Cross-browser testing status

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 to provide a simpler and more reusable option.

Read the introductory blog post for more information.

Using the editor

You need jQuery, jQuery UI (1.10+), and Rangy loaded. An easy way to do this is to use Google's JS service:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<script src="http://rangy.googlecode.com/svn/trunk/currentrelease/rangy-core.js"></script>

The editor toolbar is using jQuery UI theming, so you'll probably also want to grab a theme that fits your needs. Toolbar pluggins use icons from Font Awesome. Check these integration instructions for the right way to include Font Awesome depending on if/how you use Twitter Bootstrap. To style the toolbar as it appears in the demo, you'll also want to add some CSS (like background and border) to the class hallotoolbar.

<link rel="stylesheet" href="/path/to/your/jquery-ui.css">
<link rel="stylesheet" href="/path/to/your/font-awesome.css">

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. Even simple things like bold and italic are plugins:

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.

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

Events

Hallo provides some events that are useful for integration. You can use jQuery bind to subscribe to them:

  • halloenabled: Triggered when an editable is enabled (editable set to true)
  • hallodisabled: Triggered when an editable is disabled (editable set to false)
  • hallomodified: Triggered whenever user has changed the contents being edited. Event data key content contains the HTML
  • halloactivated: Triggered when user activates an editable area (usually by clicking it)
  • hallodeactivated: Triggered when user deactivates an editable area

Plugins

  • halloformat - Adds Bold, Italic, StrikeThrough and Underline support to the toolbar. (Enable/Disable with options: "formattings": {"bold": true, "italic": true, "strikethrough": true, "underline": false})
  • halloheadings - Adds support for H1, H2, H3. You can pass a headings option key to specify what is going to be displayed (e.g. "formatBlocks":["p", "h2","h3"])
  • 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)
  • halloimage - Image uploading, searching, suggestions
  • halloblacklist - Filtering unwanted tags from the content

Licensing

Hallo is free software available under the MIT license.

Contributing

Hallo is written in CoffeeScript, a simple language that compiles into JavaScript. You'll need Node.js to to build it. All build dependencies can be installed with:

$ npm install

To generate the JavaScript code to dist/hallo.js from Hallo sources, run Grunt:

$ grunt build

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

Unit tests

We use the Travis continuous integration service for testing Hallo. Currently we run two types of tests:

You can run the unit tests locally by opening test/index.html in your browser, or with PhantomJS by running:

$ grunt test

or:

$ npm test

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 some additional options:

  • editable: The main Hallo widget instance
  • uuid: unique identifier of the Hallo instance, can be used for element IDs

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",
    boldElement: null

    options:
      uuid: ''
      editable: null

    _create: ->
      # Add any actions you want to run on plugin initialization
      # here

    populateToolbar: (toolbar) ->
      # Create an element for holding the button
      @boldElement = jQuery '<span></span>'

      # Use Hallo Button
      @boldElement.hallobutton
        uuid: @options.uuid
        editable: @options.editable
        label: 'Bold'
        # Icons come from Font Awesome
        icon: 'icon-bold'
        # Commands are used for execCommand and queryCommandState
        command: 'bold'

      # Append the button to toolbar
      toolbar.append @boldElement

    cleanupContentClone: (element) ->
      # Perform content clean-ups before HTML is sent out

)(jQuery)

More Repositories

1

create

Midgard Create, a generic web editing interface for any CMS
JavaScript
2,473
star
2

dnode-php

DNode RPC protocol implementation for PHP
PHP
429
star
3

VIE

Semantic Interaction Framework for JavaScript
JavaScript
303
star
4

where

Geographical utilities for location-based Node.js applications
JavaScript
56
star
5

MidgardAppServerBundle

Run Symfony2 applications on the AppServer-in-PHP
PHP
46
star
6

blogsiple

Simple NodeXT CMS serving as the official Create integration testbed
JavaScript
31
star
7

ViePalsu

Collaborative meeting tool
CoffeeScript
27
star
8

resource-juggling

CRUD in Node.js made easy
CoffeeScript
24
star
9

dotfiles

My Linux dotfiles
Vim Script
23
star
10

nodext

Plugin-driven Node.js applications
CoffeeScript
19
star
11

noweb.php

Literate programming tool for PHP
PHP
18
star
12

actionbar

Android-style Action Bar for Backbone.js
JavaScript
15
star
13

midgardmvc_helper_urlize

Clean URL name generator for PHP
PHP
10
star
14

flowcopter

NoFlo and AR.Drone examples
HTML
7
star
15

zombie-qunit

Example of running QUnit client-side tests with the Zombie headless browser
JavaScript
7
star
16

MidgardToolbarBundle

Simple toolbars system for Symfony2
PHP
6
star
17

MidgardMvcCompatBundle

Compatibility bundle for running Midgard MVC components and applications in Symfony2
PHP
6
star
18

org_couchdb_replication

Midgard MVC interface to CouchDb replication protocol
PHP
5
star
19

urlizer_service

Heroku PHP app for converting strings to clean URL names
PHP
5
star
20

subethaedit-zenburn

Zenburn color schemes for the SubEthaEdit collaborative editor
5
star
21

midgardmvc_helper_location

Location services for Midgard MVC
PHP
5
star
22

talks

Various presentation slides
CSS
5
star
23

nodext-create

Create CMS UI extension for nodext
CoffeeScript
4
star
24

buscatcher

See Helsinki buses and trams moving on map in real time
Python
4
star
25

midgardmvc_helper_workflow

Workflow engine for Midgard MVC
PHP
4
star
26

xpress-demo

noflo-xpress demo app
JavaScript
4
star
27

basecamptools

Tools for working with Basecamp
PHP
3
star
28

net_nemein_avaudu

Midgard2 based microblogging client
JavaScript
3
star
29

wikipedia2poi

Script for populating maemomapper POI database with local Wikipedia entries
3
star
30

midgardmvc_ui_forms

Forms designer for Midgard MVC
PHP
3
star
31

MidgardConnectionBundle

Midgard2 repository connection for Symfony2
PHP
3
star
32

org_midgardproject_productsite

Midgard-based product site system for Open Source apps
JavaScript
3
star
33

node-socket-repeater

CoffeeScript
3
star
34

Symfony2ForMidgardians

Symfony2 tutorial for Midgard developers
2
star
35

org_midgardproject_documentation

Midgard documentation viewer
PHP
2
star
36

ocs-test

Open Collaboration Services API tests
CoffeeScript
2
star
37

quteqaiku

QML Qaiku client
C++
2
star
38

bergie.github.com

Sources for my website
HTML
2
star
39

midgardmvc_ui_learn

Midgard MVC documentation browser
PHP
2
star
40

MidgardMidcomCompatBundle

Compatibility bundle for running MidCOM 8.09 components and applications in Symfony2
PHP
2
star
41

heroku-buildpack-midgardmvc

Heroku build pack for Midgard MVC PHP applications
Shell
2
star
42

org_midgardproject_news

News aggregation and display component for Midgard Project website
PHP
2
star
43

playfield

1
star
44

grunt-component

Wrapper around component(1) for grunt
JavaScript
1
star
45

tmp

Testing stuff
CoffeeScript
1
star
46

heroku-buildpack-midgard-mvc

Heroku buildpack for running Midgard MVC applications
1
star
47

noadmin-noflo-components

NoFlo components for the NoAdmin PoC
1
star
48

routabackup

Batch process for backing up an old MidCOM site from Wayback Machine
CoffeeScript
1
star
49

dwm

My custom version of dwm
C
1
star