]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/core/ckeditor.js
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
7 * @fileOverview Contains the third and last part of the {@link CKEDITOR} object
11 /** @class CKEDITOR */
13 // Remove the CKEDITOR.loadFullCore reference defined on ckeditor_basic.
14 delete CKEDITOR
.loadFullCore
;
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.
21 * alert( CKEDITOR.instances.editor1.name ); // 'editor1'
25 CKEDITOR
.instances
= {};
28 * The document of the window storing the CKEDITOR object.
30 * alert( CKEDITOR.document.getBody().getName() ); // 'body'
32 * @property {CKEDITOR.dom.document}
34 CKEDITOR
.document
= new CKEDITOR
.dom
.document( document
);
37 * Adds an editor instance to the global {@link CKEDITOR} object. This function
38 * is available for internal use mainly.
40 * @param {CKEDITOR.editor} editor The editor instance to be added.
42 CKEDITOR
.add = function( editor
) {
43 CKEDITOR
.instances
[ editor
.name
] = editor
;
45 editor
.on( 'focus', function() {
46 if ( CKEDITOR
.currentInstance
!= editor
) {
47 CKEDITOR
.currentInstance
= editor
;
48 CKEDITOR
.fire( 'currentInstance' );
52 editor
.on( 'blur', function() {
53 if ( CKEDITOR
.currentInstance
== editor
) {
54 CKEDITOR
.currentInstance
= null;
55 CKEDITOR
.fire( 'currentInstance' );
59 CKEDITOR
.fire( 'instance', null, editor
);
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}.
67 * @param {CKEDITOR.editor} editor The editor instance to be removed.
69 CKEDITOR
.remove = function( editor
) {
70 delete CKEDITOR
.instances
[ editor
.name
];
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.
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.
85 CKEDITOR
.addTemplate = function( name
, source
) {
86 var tpl
= tpls
[ name
];
90 // Make it possible to customize the template through event.
91 var params
= { name: name
, source: source
};
92 CKEDITOR
.fire( 'template', params
);
94 return ( tpls
[ name
] = new CKEDITOR
.template( params
.source
) );
98 * Retrieves a defined template created with {@link CKEDITOR#addTemplate}.
100 * @param {String} name The template name.
102 CKEDITOR
.getTemplate = function( name
) {
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
116 * **Note:** This function should be called before the creation of editor instances.
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 }' );
121 * @param {String} css The style rules to be appended.
122 * @see CKEDITOR.config#contentsCss
124 CKEDITOR
.addCss = function( css
) {
129 * Returns a string will all CSS rules passed to the {@link CKEDITOR#addCss} method.
131 * @returns {String} A string containing CSS rules.
133 CKEDITOR
.getCss = function() {
134 return styles
.join( '\n' );
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' );
145 // Load the bootstrap script.
146 CKEDITOR
.loader
.load( '_bootstrap' ); // %REMOVE_LINE%
148 // Tri-state constants.
150 * Used to indicate the ON or ACTIVE state.
153 * @property {Number} [=1]
155 CKEDITOR
.TRISTATE_ON
= 1;
158 * Used to indicate the OFF or INACTIVE state.
161 * @property {Number} [=2]
163 CKEDITOR
.TRISTATE_OFF
= 2;
166 * Used to indicate the DISABLED state.
169 * @property {Number} [=0]
171 CKEDITOR
.TRISTATE_DISABLED
= 0;
174 * The editor which is currently active (has user focus).
176 * function showCurrentEditorName() {
177 * if ( CKEDITOR.currentInstance )
178 * alert( CKEDITOR.currentInstance.name );
180 * alert( 'Please focus an editor first.' );
183 * @property {CKEDITOR.editor} currentInstance
184 * @see CKEDITOR#event-currentInstance
188 * Fired when the CKEDITOR.currentInstance object reference changes. This may
189 * happen when setting the focus on different editor instances in the page.
191 * var editor; // A variable to store a reference to the current editor.
192 * CKEDITOR.on( 'currentInstance', function() {
193 * editor = CKEDITOR.currentInstance;
196 * @event currentInstance
200 * Fired when the last instance has been destroyed. This event is used to perform
201 * global memory cleanup.