From: Aleksander Ɓukasz Date: Tue, 9 Jul 2013 15:31:43 +0000 (+0200) Subject: Fixing white space handling X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/8254ff82e19d41b2a66a4549165b924084ed6a52?ds=inline Fixing white space handling --- diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index ba7daef..6131e4e 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -53,7 +53,10 @@ $.extend(Canvas.prototype, { + (endSpace && (spanParent || spanAfter) ? ' ' : ''); } else { + var oldLength = this.data.length; this.data = $.trim(this.data); + if(this.data.length === 0 && oldLength > 0) + this.data = ' '; } }); diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 5aa4aad..77b3b19 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -162,6 +162,7 @@ describe('Canvas', function() { var c = canvas.fromXML('
'); expect(c.doc().children().length).to.equal(1); expect(c.doc().children()[0]).to.be.instanceOf(documentElement.DocumentTextElement); + expect(c.doc().children()[0].getText()).to.equal(' '); }); it('ignores white space surrounding block elements', function() { var c = canvas.fromXML('
');