开发者

Django CMS / WYMEditor Stop Stripping of Whitespace

开发者 https://www.devze.com 2023-03-04 12:36 出处:网络
I\'m aware of what WYMEditor is all about and that using Paragraphs for spacing is not intended, however the problem here is with the client requiring that we give them this functionality.

I'm aware of what WYMEditor is all about and that using Paragraphs for spacing is not intended, however the problem here is with the client requiring that we give them this functionality.

I've looked high and low to find where WYMEditor does it's stripping of whitespace and can't seem to find it at all.

It seems that when you 开发者_开发问答press enter it creates a P visually, however when clicking the source it doesn't contain it. Furthermore, manually editing HTML source to contain <p>&nbsp;</p> doesn't work, as WYMEditor strips it out.

Just wondering if anybody has had this issue before and knows how to get rid of this functionality? It's worth noting that I believe the replacement is happening both in the 'text' module of Django-CMS, and also in the Javascript for WYMEditor.


Turns out, the function that does this stripping is very simply named, for some reason I missed it in (multiple!) searches for the word 'empty' in the script file.

It's located in jquery.wymeditor.js, line ~3440 there is the function WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags, simply stop the replacement:

WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags = function(xhtml)
{
   return xhtml;// .replace(new RegExp('<('+this.block_tags.join("|").replace(/\|td/,'').replace(/\|th/, '')+')>(<br \/>|&#160;|&nbsp;|\\s)*<\/\\1>' ,'g'),'');
};

That obviously stops the stripping of whitespace!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号