equal
deleted
inserted
replaced
|
1 /** |
|
2 * plugin.js |
|
3 * |
|
4 * Copyright, Moxiecode Systems AB |
|
5 * Released under LGPL License. |
|
6 * |
|
7 * License: http://www.tinymce.com/license |
|
8 * Contributing: http://www.tinymce.com/contributing |
|
9 */ |
|
10 |
|
11 /*global tinymce:true */ |
|
12 |
|
13 tinymce.PluginManager.add('nonbreaking', function(editor) { |
|
14 var setting = editor.getParam('nonbreaking_force_tab'); |
|
15 |
|
16 editor.addCommand('mceNonBreaking', function() { |
|
17 editor.insertContent( |
|
18 (editor.plugins.visualchars && editor.plugins.visualchars.state) ? |
|
19 '<span class="mce-nbsp"> </span>' : ' ' |
|
20 ); |
|
21 |
|
22 editor.dom.setAttrib(editor.dom.select('span.mce-nbsp'), 'data-mce-bogus', '1'); |
|
23 }); |
|
24 |
|
25 editor.addButton('nonbreaking', { |
|
26 title: 'Nonbreaking space', |
|
27 cmd: 'mceNonBreaking' |
|
28 }); |
|
29 |
|
30 editor.addMenuItem('nonbreaking', { |
|
31 text: 'Nonbreaking space', |
|
32 cmd: 'mceNonBreaking', |
|
33 context: 'insert' |
|
34 }); |
|
35 |
|
36 if (setting) { |
|
37 var spaces = +setting > 1 ? +setting : 3; // defaults to 3 spaces if setting is true (or 1) |
|
38 |
|
39 editor.on('keydown', function(e) { |
|
40 if (e.keyCode == 9) { |
|
41 |
|
42 if (e.shiftKey) { |
|
43 return; |
|
44 } |
|
45 |
|
46 e.preventDefault(); |
|
47 for (var i = 0; i < spaces; i++) { |
|
48 editor.execCommand('mceNonBreaking'); |
|
49 } |
|
50 } |
|
51 }); |
|
52 } |
|
53 }); |