Posted on 09/06/2021 11:42:52
Hi,
I've been trying to tweak around with CKEditor to do some different things like stripping down font-family from when the user copy pastes into the editor.
According to their documentation, the Advanced Content filter in automatic mode should strip down any style that isn't available in the UI.
' By default it is enabled and works in automatic mode, which means that CKEditor will only accept content that was defined as allowed by enabled CKEditor features (such as plugins or buttons).' - https://ckeditor.com/docs/ckeditor4/latest/examples/acf.html
So I tried to remove the font plugin with
config.removePlugins = 'font';
And it worked to remove the font dropdown from the UI, but the font-family is still not being filtered out as it should.
I also tried achieving the same thing by using disallowedContent as:
config.disallowedContent = 'span{font,font-size,font-family}';
But that also didn't change anything. It seems to be like the Advanced Content Filter is being disabled somewhere or just simply not working in DW.
Any ideas?
Thank you
Here's the full code I'm using:
CKEDITOR.editorConfig = function(config) {
// Define changes to default configuration here.
// For the complete reference:
// http://docs.ckeditor.com/#!/api/CKEDITOR.config
// The toolbar groups arrangement, optimized for two toolbar rows.
config.toolbarGroups = [ {
name: 'styles'
}, {
name: 'basicstyles',
groups: [ 'basicstyles', 'cleanup' ]
}, {
name: 'paragraph',
groups: [ 'list', 'indent', 'blocks', 'align' ]
}, {
name: 'clipboard',
groups: [
'clipboard', 'undo'
]
}, {
name: 'links'
}, {
name: 'insert'
}, {
name: 'tools'
}, {
name: 'document',
groups: [ 'mode', 'document', 'doctools' ]
} ];
// Remove some buttons, provided by the standard plugins, which we don't need to have in the Standard(s) toolbar.
config.removeButtons = 'Strike,Underline,Subscript,Superscript,Indent,Outdent,Styles,NewPage,Save';
config.removePlugins = 'font';
config.disallowedContent = 'span{font,font-size,font-family}';
config.stylesSet = [];
config.filebrowserBrowseUrl = '/Admin/Editor/ckeditor/browser.aspx?type=link';
config.filebrowserImageBrowseUrl = '/Admin/Editor/ckeditor/browser.aspx?type=image';
config.wordcount = {
countHTML: false, // Whether or not to include Html chars in the Char Count
maxWordCount: -1, // Maximum allowed Word Count, -1 is default for unlimited
maxCharCount: -1, // Maximum allowed Char Count, -1 is default for unlimited
showCharCount: false, // Whether or not you want to show the Char Count
showWordCount: false, // Whether or not you want to show the Word Count
showParagraphs: false, // Whether or not you want to show the Paragraphs Count
countSpacesAsChars: false, // Whether or not you want to count Spaces as Chars
};
};