Understanding the Aloha Editor core
After reading this guide, you will be able to:
- Understand how Aloha Editor initialized
- Use basic functionality the core provides
- Understand Aloha Editables, and what they do
- Core Aloha Editor events
1 Editable elements
Aloha can be used with the following HTML text elements:
[ 'a', 'abbr', 'address', 'article', 'aside', 'b', 'bdo', 'blockquote', 'cite', 'code', 'command', 'del', 'details', 'dfn', 'div', 'dl', 'em', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'i', 'ins', 'menu', 'nav', 'p', 'pre', 'q', 'ruby', 'section', 'small', 'span', 'strong', 'sub', 'sup', 'textarea', 'var' ]
Not supported HTML elements:
[ 'canvas', 'audio', 'br', 'embed', 'fieldset', 'hgroup', 'hr', 'iframe', 'img', 'input', 'map', 'script', 'select', 'style', 'svg', 'table', 'ul', 'video', 'ol', 'form', 'noscript' ]
Note if you are using a textarea with Aloha: If the textarea has a HTML ID (eg. mytxtarea) the ID of the Aloha editable will be “-aloha” suffixed (eg. mytxtarea-aloha).
2 Core files
TODO describe file contents
- src/lib/aloha.js
- src/lib/aloha-bootstrap.js
- src/lib/aloha/core.js
- …
3 Initialization Process
When Aloha Editor is loading several steps are completed until the initialization process is finished.
TODO add description for init process and events!
// init process taken from core.js Aloha.stage = 'loadPlugins'; Aloha.loadPlugins(function(){ Aloha.stage = 'initAloha'; Aloha.initAloha(function(){ Aloha.stage = 'initPlugins'; Aloha.initPlugins(function(){ Aloha.stage = 'initGui'; Aloha.initGui(function(){ Aloha.stage = 'alohaReady'; Aloha.trigger('aloha-ready'); }); }); }); });
Aloha Editor will also add a CSS class to the html DOM node during it’s initAloha
stage. The following classes will be used:
Browser | Class |
---|---|
Chrome or Safari | aloha-webkit |
Opera | aloha-opera |
Firefox | aloha-mozilla |
Opera | aloha-webkit |
Internet Explorer 7* | aloha-ie7 |
Internet Explorer 8* | aloha-ie8 |
Internet Explorer 9* | aloha-ie9 |
Internet Explorer 10* | aloha-ie10 |
* Internet Explorer Version Numbers will be derived by turning the browser version into an integer
4 How to use require
TODO describe how Aloha.require is used
5 Internationalization
TODO describe
6 Logging
TODO describe
7 Utilities
TODO describe GENTICS.Utils.dom and the like
8 Events
see: Guides page: Events
9 Editables
Documentation pending.
10 HotKeys
Documentation pending.
Add and remove HotKey handler for keyboard events supporting almost any key combination.
The syntax is as follows:
$(document).bind('keydown', 'ctrl+a', fn);
Example configuration for inserting a Link with the HotKey `Ctrl-u` (default: `Ctrl-l`)
Aloha.settings = { plugins: { link: { hotKey: { insertLink: 'ctrl+u' } } } }
- Types Supported types are `‘keydown’`, `‘keyup’` and `‘keypress’`
- Addendum Firefox is the most liberal one in the manner of letting you capture all short-cuts even those that are built-in in the browser such as `Ctrl-t` for new tab, or `Ctrl-a` for selecting all text. You can always bubble them up to the browser by returning `true` in your handler.
Others, (IE) either let you handle built-in short-cuts, but will add their functionality after your code has executed. Or (Opera/Safari) will not pass those events to the DOM at all.
So, if you bind `Ctrl-Q` or `Alt-F4` and your Safari/Opera window is closed don’t be surprised.
Code from: https://github.com/jeresig/jquery.hotkeys