outlawplz / ckeditor_templates
此包已被废弃且不再维护。未建议替代包。
此插件提供了一个对话框,以提供预定义的内容模板 - 包括页面布局、文本格式和样式。
v0.1.1
2017-03-13 16:08 UTC
This package is auto-updated.
Last update: 2020-10-04 14:36:57 UTC
README
Drupal 8自定义模块,实现了CKEditor的模板插件。
快速开始
在三个步骤中开始使用CKEditor模板。
- 从Github或通过Composer下载最新的CKEditor Templates模块,并像往常一样启用它。
composer require outlawplz/ckeditor_templates
- 下载CKEditor Templates插件,并将其复制到Drupal根目录下的
libraries/
文件夹。
# Plug-in location
/libraries/templates/plugin.js
- 编辑使用CKEditor的文本格式,并将模板插件从可用按钮拖动到活动工具栏以启用它。
就是这样。现在您可以开始使用CKEditor模板了。
选项
启用插件后,您可以通过编辑插件设置来指定模板文件的位置。可用选项有名称、路径和替换内容。
-
名称: 您的模板集名称。在下面的示例中,模板名称为
custom
。 -
路径: 模板文件的路径。在下面的示例中,路径为
/libraries/custom_templates/custom.templates.js
。 -
替换内容: 默认情况下,插入模板时是否应替换内容。
模板定义
模板在JS文件中定义。将您的模板文件保存到/libraries
文件夹或/sites/default/files
文件夹中。在这个示例中,文件将被创建到/libraries/custom_templates
文件夹中。
// The name of templates set is 'custom'. CKEDITOR.addTemplates( 'custom', { // Path to the subfolder that contains the preview images. imagesPath: '/libraries/custom_templates/images/', // Template definition. templates: [ { title: 'Custom template', image: 'custom.gif', description: 'Description of my custom template.', html: '<h2>Custom Template</h2>' + '<p>Your text...</p>' }, { title: 'Custom template with image', image: 'custom_image.gif', description: 'Description of my custom template with image.', html: '<h2>Custom Template with Image</h2>' + '<p><img src="/image.png" /></p>', '<p>Your text...</p>' } ] } );