This project has moved and is read-only. For the latest updates, please go here.

Whitespace in the beginning being trimmed?

Sep 20, 2012 at 10:42 AM


My textarea has sometimes some whitespace at the beginning, which is important to preserve, but when using jHtmlArea, that whitespace is lost. 

Is there anything I can do to avoid this?




Sep 20, 2012 at 1:21 PM

I think I've found the source of this. On jHtmlArea-0.7.5.js, around line 306, there's:

        initEditor: function (options) {
            var edit = this.editor = this.iframe[0].contentWindow.document;
            edit.designMode = 'on';
            if (options.css) {
                var e = edit.createElement('link'); e.rel = 'stylesheet'; e.type = 'text/css'; e.href = options.css; edit.getElementsByTagName('head')[0].appendChild(e);

Apparently, the write() method doesn't respect whitespace...

If I replace the lines ...


... with ...

            edit.body.textContent = this.textarea.val()

... then whitespace is preserved! but any html markup part of the textarea contents is not interpreted by the browser when copied to the iframe.

Moreover, I don't want to change the jHtmlArea source...

All help appreciated. This is a big show stopper for me :\