首页 ckeditor模板定义

ckeditor模板定义

举报
开通vip

ckeditor模板定义Templates With CKEditor, content writers can select a template from a list by clicking the "Templates" button in the toolbar. A template is a predefined piece of HTML that is placed inside the editor. In this way the user doesn't need to start writing from scr...

ckeditor模板定义
Templates With CKEditor, content writers can select a template from a list by clicking the "Templates" button in the toolbar. A template is a predefined piece of HTML that is placed inside the editor. In this way the user doesn't need to start writing from scratch. Designers can prepare well designed templates, avoiding user errors before they happen. Template Definition Files The editor comes with three sample templates that are there just to show the way it works. They are defined into the "plugins/templates/templates/default.js" file. Developers should definitely change the default templates as they are not especially useful to end users. Note that a template definition file is a JavaScript file that's loaded when opening the templates dialog for the first time. This file may be changed to include custom templates, or even better, you can create a separated template file outside the editor installation directory, configuring the editor to use it. Pointing the Editor to a Custom Templates Definitions File Assuming you have created a custom Templates Definitions file named "mytemplates.js" (starting from a copy of default.js) and have placed it into the root of your web site. Now, just add the following setting in the editor configuration: config.templates_files = [ '/mytemplates.js' ]; Note that the templates_files setting is an array, which means that more than one templates file can be used. The Templates Definitions File Contents This is a sample Template Definition file that defines two simple templates: // Register a templates definition set named "default". CKEDITOR.addTemplates( 'default', {     // The name of sub folder which hold the shortcut preview images of the templates.     imagesPath : CKEDITOR.getUrl( CKEDITOR.plugins.getPath( 'templates' ) + 'templates/images/' ),     // The templates definitions.     templates :         [             {                 title: 'My Template 1',                 image: 'template1.gif',                 description: 'Description of my template 1.',                 html:                     '

Template 1

' +                     '

Type the text here.

'             },             {                 title: 'My Template 2',                 html:                     '

Template 2

' +                     '

Type the text here.

'             }         ] }); As we can see here, the above is pure JavaScript code. It's a simple call to the CKEDITOR.addTemplates function, which registers the templates under a unique name ("default"). This name can be then used by the templates setting.
本文档为【ckeditor模板定义】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_511210
暂无简介~
格式:doc
大小:18KB
软件:Word
页数:2
分类:生活休闲
上传时间:2017-09-19
浏览量:11