Another suggestion:
CKeditor extra already have Templates plugin but missing from Toolbar configuration. We can add template by modifying toolbar configuration:
...
,{ "name": "templates", "items": [ "Templates"] }
...
Templates is one of CKEditor I like and used frequently. Template is powerful plugin and can speed up editor/writer/copywriter works. And I think it will be more powerful if we can set our own custom template.
We can add the custom template on the fly or using static js file (
http://docs.cksource.com/CKEditor_3.x/Howto/Custom_Templates). To make this work, I guess there are 2 route to provide custom template:
First, use system setting to provide custom template and call it on the fly. For example we create "ckeditor.custom_template" setting and add the value:
[
{
title: 'Articles',
description: 'Template for article',
html:
'<h2>SubTitle</h2>' +
'<p>Your text goes here</p>'
},
{
title: 'Store',
description: 'Template for bookstore',
html:
'<table class="product_desc">' +
'<tr><td>Publisher:</td><td>[publisher]</td></tr>' +
'<tr><td>Pages:</td><td>[n] pages</td></tr>' +
'<tr><td>Edition:</td><td>[x] edition</td></tr>' +
'</table>' +
}
]
Then on CKEditor init, run the code:
CKEDITOR.addTemplates( 'default', {
// imaage path: relative url to media source
imagesPath : CKEDITOR.getUrl( CKEDITOR.plugins.getPath( 'templates' ) + 'templates/images/' ),
// Template definitions.
templates : MODx.config["ckeditor.custom_template"]
});
Second, custom template is provided by our Resource with documentType as "text/javascript" and use "ckeditor.custom_template" setting to point to ResourceID.
For example: ckeditor.custom_template=10, and the content of resource is as follow:
CKEDITOR.addTemplates( 'default', {
// image path: relative url to media source
imagesPath : CKEDITOR.getUrl( [PATH/TO/MEDIA/SOURCE/] ),
// Template definitions.
templates :[
{
title: 'Articles',
description: 'Template for article',
html:
'<h2>SubTitle</h2>' +
'<p>Your text goes here</p>'
},
{
title: 'Store',
description: 'Template for bookstore',
html:
'<table class="product_desc">' +
'<tr><td>Publisher:</td><td>[publisher]</td></tr>' +
'<tr><td>Pages:</td><td>[n] pages</td></tr>' +
'<tr><td>Edition:</td><td>[x] edition</td></tr>' +
'</table>' +
}
]
});
Then on CKEditor config, change the "config.templates_files" as follow:
config.templates_files =
[
'/editor_templates/site_default.js',
'[[~[[++ckeditor.custom_template]]]]
];
I don't know which one is easier to develop. But I hope this can be implemented in CKEditor extra.