Search code examples
kendo-uieditorwysiwygkendo-editor

How to stop Kendo ui web editor from stripping white space from source view


I'm currently using the Kendo UI web inline editor to edit content and wondered if it was possible to stop the editor from removing white space around the DIV element in source view? It currently keeps the format inside DIVs but not around the DIV element itself.


Solution

  • I was looking for a simple answer to this problem too, unfortunately there doesn't seem to be one. I'm working with KendoUI 2013.3.1119, I suppose in other versions of the editor the problem will be the same.

    I was looking into the source code (kendo.web.js), where the editor is initialized. Due to a problem with ranges in IE when HTML is indented, the editor strips all whitespaces using the following line:

    value = element.val().replace(/[\r\n\v\f\t ]+/ig, " ");
    

    Since I don't work with ranges in IE (actually, I don'T use IE at home at all), I simple replaced this line with

    value = element.val();
    

    and from that point on everything worked fine.

    However, you need to be aware the this is a tweak in the kendoui core and might lead to unexpected behavious depending on your usecase.

    For those interested, the line number is 30497 in kendo.web.js.

    Regards,

    Frank