2 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
7 CKEDITOR.plugins.add( 'templates', {
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' ) );
17 editor.addCommand( 'templates', new CKEDITOR.dialogCommand( 'templates' ) );
19 editor.ui.addButton && editor.ui.addButton( 'Templates', {
20 label: editor.lang.templates.button,
22 toolbar: 'doctools,10'
28 loadedTemplatesFiles = {};
30 CKEDITOR.addTemplates = function( name, definition ) {
31 templates[ name ] = definition;
34 CKEDITOR.getTemplates = function( name ) {
35 return templates[ name ];
38 CKEDITOR.loadTemplates = function( templateFiles, callback ) {
39 // Holds the templates files to be loaded.
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;
51 CKEDITOR.scriptLoader.load( toLoad, callback );
53 setTimeout( callback, 0 );
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.
63 * config.templates = 'my_templates';
65 * @cfg {String} [templates='default']
66 * @member CKEDITOR.config
70 * The list of templates definition files to load.
72 * config.templates_files = [
73 * '/editor_templates/site_default.js',
74 * 'http://www.example.com/user_templates.js'
77 * For a sample template file
78 * [see `templates/default.js`](https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/templates/templates/default.js).
81 * @member CKEDITOR.config
83 CKEDITOR.config.templates_files = [
84 CKEDITOR.getUrl( 'plugins/templates/templates/default.js' )
88 * Whether the "Replace actual contents" checkbox is checked by default in the
91 * config.templates_replaceContent = false;
94 * @member CKEDITOR.config
96 CKEDITOR.config.templates_replaceContent = true;