]>
Commit | Line | Data |
---|---|---|
1 | /**\r | |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\r | |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license\r | |
4 | */\r | |
5 | \r | |
6 | CKEDITOR.plugins.add( 'basicstyles', {\r | |
7 | // jscs:disable maximumLineLength\r | |
8 | lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%\r | |
9 | // jscs:enable maximumLineLength\r | |
10 | icons: 'bold,italic,underline,strike,subscript,superscript', // %REMOVE_LINE_CORE%\r | |
11 | hidpi: true, // %REMOVE_LINE_CORE%\r | |
12 | init: function( editor ) {\r | |
13 | var order = 0;\r | |
14 | // All buttons use the same code to register. So, to avoid\r | |
15 | // duplications, let's use this tool function.\r | |
16 | var addButtonCommand = function( buttonName, buttonLabel, commandName, styleDefiniton ) {\r | |
17 | // Disable the command if no definition is configured.\r | |
18 | if ( !styleDefiniton )\r | |
19 | return;\r | |
20 | \r | |
21 | var style = new CKEDITOR.style( styleDefiniton ),\r | |
22 | forms = contentForms[ commandName ];\r | |
23 | \r | |
24 | // Put the style as the most important form.\r | |
25 | forms.unshift( style );\r | |
26 | \r | |
27 | // Listen to contextual style activation.\r | |
28 | editor.attachStyleStateChange( style, function( state ) {\r | |
29 | !editor.readOnly && editor.getCommand( commandName ).setState( state );\r | |
30 | } );\r | |
31 | \r | |
32 | // Create the command that can be used to apply the style.\r | |
33 | editor.addCommand( commandName, new CKEDITOR.styleCommand( style, {\r | |
34 | contentForms: forms\r | |
35 | } ) );\r | |
36 | \r | |
37 | // Register the button, if the button plugin is loaded.\r | |
38 | if ( editor.ui.addButton ) {\r | |
39 | editor.ui.addButton( buttonName, {\r | |
40 | label: buttonLabel,\r | |
41 | command: commandName,\r | |
42 | toolbar: 'basicstyles,' + ( order += 10 )\r | |
43 | } );\r | |
44 | }\r | |
45 | };\r | |
46 | \r | |
47 | var contentForms = {\r | |
48 | bold: [\r | |
49 | 'strong',\r | |
50 | 'b',\r | |
51 | [ 'span', function( el ) {\r | |
52 | var fw = el.styles[ 'font-weight' ];\r | |
53 | return fw == 'bold' || +fw >= 700;\r | |
54 | } ]\r | |
55 | ],\r | |
56 | \r | |
57 | italic: [\r | |
58 | 'em',\r | |
59 | 'i',\r | |
60 | [ 'span', function( el ) {\r | |
61 | return el.styles[ 'font-style' ] == 'italic';\r | |
62 | } ]\r | |
63 | ],\r | |
64 | \r | |
65 | underline: [\r | |
66 | 'u',\r | |
67 | [ 'span', function( el ) {\r | |
68 | return el.styles[ 'text-decoration' ] == 'underline';\r | |
69 | } ]\r | |
70 | ],\r | |
71 | \r | |
72 | strike: [\r | |
73 | 's',\r | |
74 | 'strike',\r | |
75 | [ 'span', function( el ) {\r | |
76 | return el.styles[ 'text-decoration' ] == 'line-through';\r | |
77 | } ]\r | |
78 | ],\r | |
79 | \r | |
80 | subscript: [\r | |
81 | 'sub'\r | |
82 | ],\r | |
83 | \r | |
84 | superscript: [\r | |
85 | 'sup'\r | |
86 | ]\r | |
87 | },\r | |
88 | config = editor.config,\r | |
89 | lang = editor.lang.basicstyles;\r | |
90 | \r | |
91 | addButtonCommand( 'Bold', lang.bold, 'bold', config.coreStyles_bold );\r | |
92 | addButtonCommand( 'Italic', lang.italic, 'italic', config.coreStyles_italic );\r | |
93 | addButtonCommand( 'Underline', lang.underline, 'underline', config.coreStyles_underline );\r | |
94 | addButtonCommand( 'Strike', lang.strike, 'strike', config.coreStyles_strike );\r | |
95 | addButtonCommand( 'Subscript', lang.subscript, 'subscript', config.coreStyles_subscript );\r | |
96 | addButtonCommand( 'Superscript', lang.superscript, 'superscript', config.coreStyles_superscript );\r | |
97 | \r | |
98 | editor.setKeystroke( [\r | |
99 | [ CKEDITOR.CTRL + 66 /*B*/, 'bold' ],\r | |
100 | [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ],\r | |
101 | [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ]\r | |
102 | ] );\r | |
103 | }\r | |
104 | } );\r | |
105 | \r | |
106 | // Basic Inline Styles.\r | |
107 | \r | |
108 | /**\r | |
109 | * The style definition that applies the **bold** style to the text.\r | |
110 | *\r | |
111 | * Read more in the [documentation](#!/guide/dev_basicstyles)\r | |
112 | * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).\r | |
113 | *\r | |
114 | * config.coreStyles_bold = { element: 'b', overrides: 'strong' };\r | |
115 | *\r | |
116 | * config.coreStyles_bold = {\r | |
117 | * element: 'span',\r | |
118 | * attributes: { 'class': 'Bold' }\r | |
119 | * };\r | |
120 | *\r | |
121 | * @cfg\r | |
122 | * @member CKEDITOR.config\r | |
123 | */\r | |
124 | CKEDITOR.config.coreStyles_bold = { element: 'strong', overrides: 'b' };\r | |
125 | \r | |
126 | /**\r | |
127 | * The style definition that applies the *italics* style to the text.\r | |
128 | *\r | |
129 | * Read more in the [documentation](#!/guide/dev_basicstyles)\r | |
130 | * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).\r | |
131 | *\r | |
132 | * config.coreStyles_italic = { element: 'i', overrides: 'em' };\r | |
133 | *\r | |
134 | * CKEDITOR.config.coreStyles_italic = {\r | |
135 | * element: 'span',\r | |
136 | * attributes: { 'class': 'Italic' }\r | |
137 | * };\r | |
138 | *\r | |
139 | * @cfg\r | |
140 | * @member CKEDITOR.config\r | |
141 | */\r | |
142 | CKEDITOR.config.coreStyles_italic = { element: 'em', overrides: 'i' };\r | |
143 | \r | |
144 | /**\r | |
145 | * The style definition that applies the <u>underline</u> style to the text.\r | |
146 | *\r | |
147 | * Read more in the [documentation](#!/guide/dev_basicstyles)\r | |
148 | * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).\r | |
149 | *\r | |
150 | * CKEDITOR.config.coreStyles_underline = {\r | |
151 | * element: 'span',\r | |
152 | * attributes: { 'class': 'Underline' }\r | |
153 | * };\r | |
154 | *\r | |
155 | * @cfg\r | |
156 | * @member CKEDITOR.config\r | |
157 | */\r | |
158 | CKEDITOR.config.coreStyles_underline = { element: 'u' };\r | |
159 | \r | |
160 | /**\r | |
161 | * The style definition that applies the <strike>strikethrough</strike> style to the text.\r | |
162 | *\r | |
163 | * Read more in the [documentation](#!/guide/dev_basicstyles)\r | |
164 | * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).\r | |
165 | *\r | |
166 | * CKEDITOR.config.coreStyles_strike = {\r | |
167 | * element: 'span',\r | |
168 | * attributes: { 'class': 'Strikethrough' },\r | |
169 | * overrides: 'strike'\r | |
170 | * };\r | |
171 | *\r | |
172 | * @cfg\r | |
173 | * @member CKEDITOR.config\r | |
174 | */\r | |
175 | CKEDITOR.config.coreStyles_strike = { element: 's', overrides: 'strike' };\r | |
176 | \r | |
177 | /**\r | |
178 | * The style definition that applies the subscript style to the text.\r | |
179 | *\r | |
180 | * Read more in the [documentation](#!/guide/dev_basicstyles)\r | |
181 | * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).\r | |
182 | *\r | |
183 | * CKEDITOR.config.coreStyles_subscript = {\r | |
184 | * element: 'span',\r | |
185 | * attributes: { 'class': 'Subscript' },\r | |
186 | * overrides: 'sub'\r | |
187 | * };\r | |
188 | *\r | |
189 | * @cfg\r | |
190 | * @member CKEDITOR.config\r | |
191 | */\r | |
192 | CKEDITOR.config.coreStyles_subscript = { element: 'sub' };\r | |
193 | \r | |
194 | /**\r | |
195 | * The style definition that applies the superscript style to the text.\r | |
196 | *\r | |
197 | * Read more in the [documentation](#!/guide/dev_basicstyles)\r | |
198 | * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).\r | |
199 | *\r | |
200 | * CKEDITOR.config.coreStyles_superscript = {\r | |
201 | * element: 'span',\r | |
202 | * attributes: { 'class': 'Superscript' },\r | |
203 | * overrides: 'sup'\r | |
204 | * };\r | |
205 | *\r | |
206 | * @cfg\r | |
207 | * @member CKEDITOR.config\r | |
208 | */\r | |
209 | CKEDITOR.config.coreStyles_superscript = { element: 'sup' };\r |