]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/templates/plugin.js
Upgrade to 4.5.7 and add some plugin
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / templates / plugin.js
1 /**
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5
6 ( function() {
7 CKEDITOR.plugins.add( 'templates', {
8 requires: 'dialog',
9 // jscs:disable maximumLineLength
10 lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,de-ch,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%
11 // jscs:enable maximumLineLength
12 icons: 'templates,templates-rtl', // %REMOVE_LINE_CORE%
13 hidpi: true, // %REMOVE_LINE_CORE%
14 init: function( editor ) {
15 CKEDITOR.dialog.add( 'templates', CKEDITOR.getUrl( this.path + 'dialogs/templates.js' ) );
16
17 editor.addCommand( 'templates', new CKEDITOR.dialogCommand( 'templates' ) );
18
19 editor.ui.addButton && editor.ui.addButton( 'Templates', {
20 label: editor.lang.templates.button,
21 command: 'templates',
22 toolbar: 'doctools,10'
23 } );
24 }
25 } );
26
27 var templates = {},
28 loadedTemplatesFiles = {};
29
30 CKEDITOR.addTemplates = function( name, definition ) {
31 templates[ name ] = definition;
32 };
33
34 CKEDITOR.getTemplates = function( name ) {
35 return templates[ name ];
36 };
37
38 CKEDITOR.loadTemplates = function( templateFiles, callback ) {
39 // Holds the templates files to be loaded.
40 var toLoad = [];
41
42 // Look for pending template files to get loaded.
43 for ( var i = 0, count = templateFiles.length; i < count; i++ ) {
44 if ( !loadedTemplatesFiles[ templateFiles[ i ] ] ) {
45 toLoad.push( templateFiles[ i ] );
46 loadedTemplatesFiles[ templateFiles[ i ] ] = 1;
47 }
48 }
49
50 if ( toLoad.length )
51 CKEDITOR.scriptLoader.load( toLoad, callback );
52 else
53 setTimeout( callback, 0 );
54 };
55 } )();
56
57
58
59 /**
60 * The templates definition set to use. It accepts a list of names separated by
61 * comma. It must match definitions loaded with the {@link #templates_files} setting.
62 *
63 * config.templates = 'my_templates';
64 *
65 * @cfg {String} [templates='default']
66 * @member CKEDITOR.config
67 */
68
69 /**
70 * The list of templates definition files to load.
71 *
72 * config.templates_files = [
73 * '/editor_templates/site_default.js',
74 * 'http://www.example.com/user_templates.js
75 * ];
76 *
77 * @cfg
78 * @member CKEDITOR.config
79 */
80 CKEDITOR.config.templates_files = [
81 CKEDITOR.getUrl( 'plugins/templates/templates/default.js' )
82 ];
83
84 /**
85 * Whether the "Replace actual contents" checkbox is checked by default in the
86 * Templates dialog.
87 *
88 * config.templates_replaceContent = false;
89 *
90 * @cfg
91 * @member CKEDITOR.config
92 */
93 CKEDITOR.config.templates_replaceContent = true;