Recent feature for more advanced restrictions, allowing rich text without
unwanted styling attributes. Unfortunately, the filter is not applied for
"internal" sources which apparently includes Word in Linux, so manually
execute for any contaminated contents.
CKEDITOR.on('instanceCreated', function (event) {
var editor = event.editor;
CKEDITOR.on('instanceCreated', function (event) {
var editor = event.editor;
+ var pastefilter = 'h2 h3 p ul ol li blockquote em i strong b; a[!href]; img[alt,!src]';
+
+ editor.on('paste', function (e) {
+ var html = e.data.dataValue;
+ if (!/<[^>]* style="/.test(html) && !/<font/.test(html)) return;
+
+ // force pasteFilter on contents containing styling attributes
+ var filter = new CKEDITOR.filter(pastefilter),
+ fragment = CKEDITOR.htmlParser.fragment.fromHtml(html),
+ writer = new CKEDITOR.htmlParser.basicWriter();
+ filter.applyTo(fragment);
+ fragment.writeHtml(writer);
+ e.data.dataValue = writer.getHtml();
+ });
+
editor.on('configLoaded', function () {
var config = editor.config;
config.language = 'nl';
editor.on('configLoaded', function () {
var config = editor.config;
config.language = 'nl';
config.allowedContent = true;
config.entities = false; // keep unicode
config.filebrowserImageUploadUrl = '/edit?type=img';
config.allowedContent = true;
config.entities = false; // keep unicode
config.filebrowserImageUploadUrl = '/edit?type=img';
- config.forcePasteAsPlainText = true;
+ config.pasteFilter = pastefilter;
config.contentsCss = document.styleSheets[0].href;
config.toolbar = [
['Inlinesave', '-', 'Undo', 'Redo'],
config.contentsCss = document.styleSheets[0].href;
config.toolbar = [
['Inlinesave', '-', 'Undo', 'Redo'],