]>
git.immae.eu Git - perso/Immae/Projets/packagist/ludivine-ckeditor-component.git/blob - sources/plugins/basicstyles/plugin.js
474ea09321af7ec10422704c928533709dfa1077
2 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
6 CKEDITOR
.plugins
.add( 'basicstyles', {
7 // jscs:disable maximumLineLength
8 lang: 'af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,es-mx,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,oc,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%
9 // jscs:enable maximumLineLength
10 icons: 'bold,italic,underline,strike,subscript,superscript', // %REMOVE_LINE_CORE%
11 hidpi: true, // %REMOVE_LINE_CORE%
12 init: function( editor
) {
14 // All buttons use the same code to register. So, to avoid
15 // duplications, let's use this tool function.
16 var addButtonCommand = function( buttonName
, buttonLabel
, commandName
, styleDefiniton
) {
17 // Disable the command if no definition is configured.
18 if ( !styleDefiniton
)
21 var style
= new CKEDITOR
.style( styleDefiniton
),
22 forms
= contentForms
[ commandName
];
24 // Put the style as the most important form.
25 forms
.unshift( style
);
27 // Listen to contextual style activation.
28 editor
.attachStyleStateChange( style
, function( state
) {
29 !editor
.readOnly
&& editor
.getCommand( commandName
).setState( state
);
32 // Create the command that can be used to apply the style.
33 editor
.addCommand( commandName
, new CKEDITOR
.styleCommand( style
, {
37 // Register the button, if the button plugin is loaded.
38 if ( editor
.ui
.addButton
) {
39 editor
.ui
.addButton( buttonName
, {
42 toolbar: 'basicstyles,' + ( order
+= 10 )
51 [ 'span', function( el
) {
52 var fw
= el
.styles
[ 'font-weight' ];
53 return fw
== 'bold' || +fw
>= 700;
60 [ 'span', function( el
) {
61 return el
.styles
[ 'font-style' ] == 'italic';
67 [ 'span', function( el
) {
68 return el
.styles
[ 'text-decoration' ] == 'underline';
75 [ 'span', function( el
) {
76 return el
.styles
[ 'text-decoration' ] == 'line-through';
88 config
= editor
.config
,
89 lang
= editor
.lang
.basicstyles
;
91 addButtonCommand( 'Bold', lang
.bold
, 'bold', config
.coreStyles_bold
);
92 addButtonCommand( 'Italic', lang
.italic
, 'italic', config
.coreStyles_italic
);
93 addButtonCommand( 'Underline', lang
.underline
, 'underline', config
.coreStyles_underline
);
94 addButtonCommand( 'Strike', lang
.strike
, 'strike', config
.coreStyles_strike
);
95 addButtonCommand( 'Subscript', lang
.subscript
, 'subscript', config
.coreStyles_subscript
);
96 addButtonCommand( 'Superscript', lang
.superscript
, 'superscript', config
.coreStyles_superscript
);
98 editor
.setKeystroke( [
99 [ CKEDITOR
.CTRL
+ 66 /*B*/, 'bold' ],
100 [ CKEDITOR
.CTRL
+ 73 /*I*/, 'italic' ],
101 [ CKEDITOR
.CTRL
+ 85 /*U*/, 'underline' ]
106 // Basic Inline Styles.
109 * The style definition that applies the **bold** style to the text.
111 * Read more in the [documentation](#!/guide/dev_basicstyles)
112 * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).
114 * config.coreStyles_bold = { element: 'b', overrides: 'strong' };
116 * config.coreStyles_bold = {
118 * attributes: { 'class': 'Bold' }
122 * @member CKEDITOR.config
124 CKEDITOR
.config
.coreStyles_bold
= { element: 'strong', overrides: 'b' };
127 * The style definition that applies the *italics* style to the text.
129 * Read more in the [documentation](#!/guide/dev_basicstyles)
130 * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).
132 * config.coreStyles_italic = { element: 'i', overrides: 'em' };
134 * CKEDITOR.config.coreStyles_italic = {
136 * attributes: { 'class': 'Italic' }
140 * @member CKEDITOR.config
142 CKEDITOR
.config
.coreStyles_italic
= { element: 'em', overrides: 'i' };
145 * The style definition that applies the <u>underline</u> style to the text.
147 * Read more in the [documentation](#!/guide/dev_basicstyles)
148 * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).
150 * CKEDITOR.config.coreStyles_underline = {
152 * attributes: { 'class': 'Underline' }
156 * @member CKEDITOR.config
158 CKEDITOR
.config
.coreStyles_underline
= { element: 'u' };
161 * The style definition that applies the <strike>strikethrough</strike> style to the text.
163 * Read more in the [documentation](#!/guide/dev_basicstyles)
164 * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).
166 * CKEDITOR.config.coreStyles_strike = {
168 * attributes: { 'class': 'Strikethrough' },
169 * overrides: 'strike'
173 * @member CKEDITOR.config
175 CKEDITOR
.config
.coreStyles_strike
= { element: 's', overrides: 'strike' };
178 * The style definition that applies the subscript style to the text.
180 * Read more in the [documentation](#!/guide/dev_basicstyles)
181 * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).
183 * CKEDITOR.config.coreStyles_subscript = {
185 * attributes: { 'class': 'Subscript' },
190 * @member CKEDITOR.config
192 CKEDITOR
.config
.coreStyles_subscript
= { element: 'sub' };
195 * The style definition that applies the superscript style to the text.
197 * Read more in the [documentation](#!/guide/dev_basicstyles)
198 * and see the [SDK sample](http://sdk.ckeditor.com/samples/basicstyles.html).
200 * CKEDITOR.config.coreStyles_superscript = {
202 * attributes: { 'class': 'Superscript' },
207 * @member CKEDITOR.config
209 CKEDITOR
.config
.coreStyles_superscript
= { element: 'sup' };