Jump to content

CKeditor deletes comment tags in product description


jasehead

Recommended Posts

The WYSIWYG CKeditor for CubeCart product descriptions tends to clean up a lot of code to comply with the DOM (it's a "feature").  I like to include some comments in the product description for my own use, like whether the postage weight is accurate or search terms so I can email links to customers that will return groups of products, eg.

<!--JANUARY-SALE-->

Under certain circumstances, like changing text to BOLD or even changing details in the General tab, a cleanup occurs and comment tags can be deleted.  It didn't seem to happen as often if the first thing I did when editing a product was to go to the description and select source - but I wanted to guarantee that it would not happen.

So I've made two changes to includes/ckeditor/config.js

CKEDITOR.editorConfig = function( config ) {
	config.allowedContent = true; // was bottom line, now moved to top
	config.filebrowserBrowseUrl = document.location.pathname+'?_g=filemanager&mode=fck';
	config.protectedSource.push(/{[\s\S]*?}/g);
	config.protectedSource.push(/<!--[\s\S]*?\>/g); // allow <comment> tag
	config.extraPlugins = 'showprotected';
	config.filebrowserWindowHeight  = 500;
	config.filebrowserWindowWidth  = 650;
};

I also noticed that where some comments HAD been deleted, the comments that remained untouched were inside <p></p> tags, so I now include comments inside paragraph tags rather than just floating by themselves.

For anyone else with other kinds of code tags being deleted, try a search for config.protectedSource.push to find the regular expressions you need.  If changing the CKeditor config doesn't fix the problem, try nesting your code inside tags that seem protected.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...