diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-01-20 00:55:51 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-01-20 00:55:51 +0100 |
commit | c63493c899de714b05b0521bb38aab60d19030ef (patch) | |
tree | fcb2b261afa0f3c2bd6b48929b64724c71192bae /sources/core/ckeditor.js | |
download | ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.tar.gz ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.tar.zst ludivine-ckeditor-component-c63493c899de714b05b0521bb38aab60d19030ef.zip |
Validation initiale4.6.2.1
Diffstat (limited to 'sources/core/ckeditor.js')
-rw-r--r-- | sources/core/ckeditor.js | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/sources/core/ckeditor.js b/sources/core/ckeditor.js new file mode 100644 index 0000000..2756204 --- /dev/null +++ b/sources/core/ckeditor.js | |||
@@ -0,0 +1,204 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | ||
4 | */ | ||
5 | |||
6 | /** | ||
7 | * @fileOverview Contains the third and last part of the {@link CKEDITOR} object | ||
8 | * definition. | ||
9 | */ | ||
10 | |||
11 | /** @class CKEDITOR */ | ||
12 | |||
13 | // Remove the CKEDITOR.loadFullCore reference defined on ckeditor_basic. | ||
14 | delete CKEDITOR.loadFullCore; | ||
15 | |||
16 | /** | ||
17 | * Stores references to all editor instances created. The name of the properties | ||
18 | * in this object correspond to instance names, and their values contain the | ||
19 | * {@link CKEDITOR.editor} object representing them. | ||
20 | * | ||
21 | * alert( CKEDITOR.instances.editor1.name ); // 'editor1' | ||
22 | * | ||
23 | * @property {Object} | ||
24 | */ | ||
25 | CKEDITOR.instances = {}; | ||
26 | |||
27 | /** | ||
28 | * The document of the window storing the CKEDITOR object. | ||
29 | * | ||
30 | * alert( CKEDITOR.document.getBody().getName() ); // 'body' | ||
31 | * | ||
32 | * @property {CKEDITOR.dom.document} | ||
33 | */ | ||
34 | CKEDITOR.document = new CKEDITOR.dom.document( document ); | ||
35 | |||
36 | /** | ||
37 | * Adds an editor instance to the global {@link CKEDITOR} object. This function | ||
38 | * is available for internal use mainly. | ||
39 | * | ||
40 | * @param {CKEDITOR.editor} editor The editor instance to be added. | ||
41 | */ | ||
42 | CKEDITOR.add = function( editor ) { | ||
43 | CKEDITOR.instances[ editor.name ] = editor; | ||
44 | |||
45 | editor.on( 'focus', function() { | ||
46 | if ( CKEDITOR.currentInstance != editor ) { | ||
47 | CKEDITOR.currentInstance = editor; | ||
48 | CKEDITOR.fire( 'currentInstance' ); | ||
49 | } | ||
50 | } ); | ||
51 | |||
52 | editor.on( 'blur', function() { | ||
53 | if ( CKEDITOR.currentInstance == editor ) { | ||
54 | CKEDITOR.currentInstance = null; | ||
55 | CKEDITOR.fire( 'currentInstance' ); | ||
56 | } | ||
57 | } ); | ||
58 | |||
59 | CKEDITOR.fire( 'instance', null, editor ); | ||
60 | }; | ||
61 | |||
62 | /** | ||
63 | * Removes an editor instance from the global {@link CKEDITOR} object. This function | ||
64 | * is available for internal use only. External code must use {@link CKEDITOR.editor#method-destroy}. | ||
65 | * | ||
66 | * @private | ||
67 | * @param {CKEDITOR.editor} editor The editor instance to be removed. | ||
68 | */ | ||
69 | CKEDITOR.remove = function( editor ) { | ||
70 | delete CKEDITOR.instances[ editor.name ]; | ||
71 | }; | ||
72 | |||
73 | ( function() { | ||
74 | var tpls = {}; | ||
75 | |||
76 | /** | ||
77 | * Adds a named {@link CKEDITOR.template} instance to be reused among all editors. | ||
78 | * This will return the existing one if a template with same name is already | ||
79 | * defined. Additionally, it fires the "template" event to allow template source customization. | ||
80 | * | ||
81 | * @param {String} name The name which identifies a UI template. | ||
82 | * @param {String} source The source string for constructing this template. | ||
83 | * @returns {CKEDITOR.template} The created template instance. | ||
84 | */ | ||
85 | CKEDITOR.addTemplate = function( name, source ) { | ||
86 | var tpl = tpls[ name ]; | ||
87 | if ( tpl ) | ||
88 | return tpl; | ||
89 | |||
90 | // Make it possible to customize the template through event. | ||
91 | var params = { name: name, source: source }; | ||
92 | CKEDITOR.fire( 'template', params ); | ||
93 | |||
94 | return ( tpls[ name ] = new CKEDITOR.template( params.source ) ); | ||
95 | }; | ||
96 | |||
97 | /** | ||
98 | * Retrieves a defined template created with {@link CKEDITOR#addTemplate}. | ||
99 | * | ||
100 | * @param {String} name The template name. | ||
101 | */ | ||
102 | CKEDITOR.getTemplate = function( name ) { | ||
103 | return tpls[ name ]; | ||
104 | }; | ||
105 | } )(); | ||
106 | |||
107 | ( function() { | ||
108 | var styles = []; | ||
109 | |||
110 | /** | ||
111 | * Adds CSS rules to be appended to the editor document. | ||
112 | * This method is mostly used by plugins to add custom styles to the editor | ||
113 | * document. For basic content styling the `contents.css` file should be | ||
114 | * used instead. | ||
115 | * | ||
116 | * **Note:** This function should be called before the creation of editor instances. | ||
117 | * | ||
118 | * // Add styles for all headings inside editable contents. | ||
119 | * CKEDITOR.addCss( '.cke_editable h1,.cke_editable h2,.cke_editable h3 { border-bottom: 1px dotted red }' ); | ||
120 | * | ||
121 | * @param {String} css The style rules to be appended. | ||
122 | * @see CKEDITOR.config#contentsCss | ||
123 | */ | ||
124 | CKEDITOR.addCss = function( css ) { | ||
125 | styles.push( css ); | ||
126 | }; | ||
127 | |||
128 | /** | ||
129 | * Returns a string will all CSS rules passed to the {@link CKEDITOR#addCss} method. | ||
130 | * | ||
131 | * @returns {String} A string containing CSS rules. | ||
132 | */ | ||
133 | CKEDITOR.getCss = function() { | ||
134 | return styles.join( '\n' ); | ||
135 | }; | ||
136 | } )(); | ||
137 | |||
138 | // Perform global clean up to free as much memory as possible | ||
139 | // when there are no instances left | ||
140 | CKEDITOR.on( 'instanceDestroyed', function() { | ||
141 | if ( CKEDITOR.tools.isEmpty( this.instances ) ) | ||
142 | CKEDITOR.fire( 'reset' ); | ||
143 | } ); | ||
144 | |||
145 | // Load the bootstrap script. | ||
146 | CKEDITOR.loader.load( '_bootstrap' ); // %REMOVE_LINE% | ||
147 | |||
148 | // Tri-state constants. | ||
149 | /** | ||
150 | * Used to indicate the ON or ACTIVE state. | ||
151 | * | ||
152 | * @readonly | ||
153 | * @property {Number} [=1] | ||
154 | */ | ||
155 | CKEDITOR.TRISTATE_ON = 1; | ||
156 | |||
157 | /** | ||
158 | * Used to indicate the OFF or INACTIVE state. | ||
159 | * | ||
160 | * @readonly | ||
161 | * @property {Number} [=2] | ||
162 | */ | ||
163 | CKEDITOR.TRISTATE_OFF = 2; | ||
164 | |||
165 | /** | ||
166 | * Used to indicate the DISABLED state. | ||
167 | * | ||
168 | * @readonly | ||
169 | * @property {Number} [=0] | ||
170 | */ | ||
171 | CKEDITOR.TRISTATE_DISABLED = 0; | ||
172 | |||
173 | /** | ||
174 | * The editor which is currently active (has user focus). | ||
175 | * | ||
176 | * function showCurrentEditorName() { | ||
177 | * if ( CKEDITOR.currentInstance ) | ||
178 | * alert( CKEDITOR.currentInstance.name ); | ||
179 | * else | ||
180 | * alert( 'Please focus an editor first.' ); | ||
181 | * } | ||
182 | * | ||
183 | * @property {CKEDITOR.editor} currentInstance | ||
184 | * @see CKEDITOR#event-currentInstance | ||
185 | */ | ||
186 | |||
187 | /** | ||
188 | * Fired when the CKEDITOR.currentInstance object reference changes. This may | ||
189 | * happen when setting the focus on different editor instances in the page. | ||
190 | * | ||
191 | * var editor; // A variable to store a reference to the current editor. | ||
192 | * CKEDITOR.on( 'currentInstance', function() { | ||
193 | * editor = CKEDITOR.currentInstance; | ||
194 | * } ); | ||
195 | * | ||
196 | * @event currentInstance | ||
197 | */ | ||
198 | |||
199 | /** | ||
200 | * Fired when the last instance has been destroyed. This event is used to perform | ||
201 | * global memory cleanup. | ||
202 | * | ||
203 | * @event reset | ||
204 | */ | ||