[TASK] CKEditor RTE: Add button to insert soft hyphen
[Packages/TYPO3.CMS.git] / typo3 / sysext / rte_ckeditor / Resources / Public / JavaScript / Plugins / softhyphen / plugin.js
1 /**
2 * soft hyphen character for CKEditor
3 */
4 CKEDITOR.plugins.add("softhyphen", {
5 lang: "da,de,en,fr,he,hr,hu,it,nl,ru", // lang: "ar,ca,da,de,el,en,es,eu,fa,fi,fr,he,hr,hu,it,ja,nl,no,pl,pt,pt-br,ru,sk,sv,tr,zh-cn"
6 icons: 'softhyphen',
7 hidpi: true,
8 init: function (editor) {
9
10 // Default Config
11 var defaultConfig = {
12 enableShortcut: true
13 };
14 var config = CKEDITOR.tools.extend(defaultConfig, editor.config.softhyphen || {}, true);
15
16 // create command "insertSoftHyphen" which inserts the invisible html tag `­`
17 editor.addCommand('insertSoftHyphen', {
18 exec: function (editor) {
19 editor.insertHtml('­');
20 }
21 });
22
23 if (config.enableShortcut) {
24 // enable shortcut ctrl+dash to insert a soft hyphen
25 editor.setKeystroke(CKEDITOR.CTRL + 189 /* char 189 = dash */, 'insertSoftHyphen');
26 }
27
28 // add additional button to insert a soft hyphen via CKEditor toolbar
29 editor.ui.addButton && editor.ui.addButton('softHyphen', {
30 label: editor.lang.softhyphen.InsertButton,
31 command: 'insertSoftHyphen',
32 toolbar: 'insertcharacters',
33 icon: 'softhyphen'
34 });
35 }
36 });