Aloha Editor

Aloha Editor Guides

These guides help you to make your content editable and to develop Aloha Editor.

Characterpicker Plugin

The Characterpicker Plugin allows you to insert special characters into your text. Position your cursor, click the icon and choose the character you’d like to insert from the overlay menu.

1 Functional Description

In order to insert a special character move the cursor to the desired position and open the “Insert” tab at the Aloha Editor. Now click on the characterpicker button and choose a special character from the table. To delete a special character just mark the special character and press backspace or delete.

1.1 Components

  • characterpicker – brings up the overlay to select a character

1.2 Configuration settings

Characters/Symbols are defined in the plugins configuration in the following format:


/**
 * @typedef {object} SymbolDefinition
 * @prop {string} label The human readable name of the symbol to be inserted.
 * @prop {string} symbol The XML entity code that will be inserted, i.E. "&#8482".
 * @prop {Array.<string>} keywords A list of strings that are used for searches to find this symbol.
 * @prop {string=} icon A icon which will be displayed in the picker instead of the symbol itself. Primarily used for symbols which render invisible characters.
 */
/** @type {Array.<SymbolDefinition>} */
Aloha.settings.plugins.characterpicker.config = [
	{
		'label': 'Non-breaking space',
		'symbol': '&nbsp;',
		'keywords': ['space', 'non', 'breaking', 'nbsp'],
		'icon': 'space_bar'
	},
	{
		'label': 'Quotation mark',
		'symbol': '&#34',
		'keywords': ['quote']
	},
];

It is possible to configure the global character set and to configure character sets for specific editables (identified by jQuery selectors):


Aloha.settings = {
	plugins: {
		characterpicker: {
			// this is the global setting
			config: [
				{
					'label': 'Trade mark sign',
					'symbol': '&#8482',
					'keywords': ['trade', 'trademark', 'tm']
				},
				{
					'label': 'Pilcrow sign',
					'symbol': '&#182',
					'keywords': ['pilcrow', 'paragraph']
				},
				{
					'label': 'Degree sign',
					'symbol': '&#176',
					'keywords': ['degree']
				},
			],
			editables: {
				// this will disable the characterpicker for the header
				'#header': [],
				// allow more characters for editables with class 'article'
				'.article': [
					{
						'label': 'Pi symbol',
						'symbol': '&#982',
						'keywords': ['pi']
					},
					{
						'label': 'Prime',
						'symbol': '&#8242',
						'keywords': ['prime', 'math']
					},
					{
						'label': 'Double prime',
						'symbol': '&#8243',
						'keywords': ['doubleprime', 'prime', 'math']
					},
				]
			}
		}
	}
}