Open spacevoyager78 opened 5 years ago
It's more a feature request, as introducing support for source mode requires much work to allow only certain classes to be preserved between two modes and, at the same time, not expose internal classes in source mode.
Probably related to #3516, due to the need of tracking which part of HTML code corresponds to which part of WYSIWYG output.
I found out that even without going to Source mode, the class disappears when I'm calling getData() when I want to save the contents. So, I'm unable to save the contents and reload them without losing this class.
Show Blocks plugin provides the option to exclude an element from being marked by it, by using a class "cke_show_blocks_off", as it was introduced here: https://dev.ckeditor.com/ticket/10884 However, such class is automatically removed when I go to Source mode due to default rules of htmldataprocessor: https://github.com/ckeditor/ckeditor4/blob/major/core/htmldataprocessor.js#L749
Go to https://jsfiddle.net/148xmv3j/1/. Initially, "cke_show_blocks_off" works and the first paragraph is not marked, but hit Source button and the "cke_show_blocks_off" class is removed. So, every time I go to Source mode, I have to manually insert the class. Using a negative lookahead fixes it:
value.replace( /(?:^|\s+)(?!cke_show_blocks_off\s)cke_[^\s]*/g, '' );