2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
8 CKEDITOR.plugins.add( 'templates',
10 requires : [ 'dialog' ],
12 init : function( editor )
14 CKEDITOR.dialog.add( 'templates', CKEDITOR.getUrl( this.path + 'dialogs/templates.js' ) );
16 editor.addCommand( 'templates', new CKEDITOR.dialogCommand( 'templates' ) );
18 editor.ui.addButton( 'Templates',
20 label : editor.lang.templates.button,
27 loadedTemplatesFiles = {};
29 CKEDITOR.addTemplates = function( name, definition )
31 templates[ name ] = definition;
34 CKEDITOR.getTemplates = function( name )
36 return templates[ name ];
39 CKEDITOR.loadTemplates = function( templateFiles, callback )
41 // Holds the templates files to be loaded.
44 // Look for pending template files to get loaded.
45 for ( var i = 0, count = templateFiles.length ; i < count ; i++ )
47 if ( !loadedTemplatesFiles[ templateFiles[ i ] ] )
49 toLoad.push( templateFiles[ i ] );
50 loadedTemplatesFiles[ templateFiles[ i ] ] = 1;
55 CKEDITOR.scriptLoader.load( toLoad, callback );
57 setTimeout( callback, 0 );
64 * The templates definition set to use. It accepts a list of names separated by
65 * comma. It must match definitions loaded with the templates_files setting.
69 * config.templates = 'my_templates';
73 * The list of templates definition files to load.
74 * @type (String) Array
75 * @default [ 'plugins/templates/templates/default.js' ]
77 * config.templates_files =
79 * '/editor_templates/site_default.js',
80 * 'http://www.example.com/user_templates.js
84 CKEDITOR.config.templates_files =
87 '_source/' + // @Packager.RemoveLine
88 'plugins/templates/templates/default.js' )
92 * Whether the "Replace actual contents" checkbox is checked by default in the
97 * config.templates_replaceContent = false;
99 CKEDITOR.config.templates_replaceContent = true;