Security update for Core, with self-updated composer
[yaffs-website] / web / libraries / templates / plugin.js
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 ( function() {
7         CKEDITOR.plugins.add( 'templates', {
8                 requires: 'dialog',
9                 // jscs:disable maximumLineLength
10                 lang: 'af,ar,az,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,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%
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  * For a sample template file
78  * [see `templates/default.js`](https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/templates/templates/default.js).
79  *
80  * @cfg {String[]}
81  * @member CKEDITOR.config
82  */
83 CKEDITOR.config.templates_files = [
84         CKEDITOR.getUrl( 'plugins/templates/templates/default.js' )
85 ];
86
87 /**
88  * Whether the "Replace actual contents" checkbox is checked by default in the
89  * Templates dialog.
90  *
91  *              config.templates_replaceContent = false;
92  *
93  * @cfg {Boolean}
94  * @member CKEDITOR.config
95  */
96 CKEDITOR.config.templates_replaceContent = true;