From ad53b82301a7b59e8a1795415fadff550384b15a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 20 Jun 2013 09:46:14 +0200 Subject: [PATCH 1/1] documentCanvas fix: fixing end of node recognition on node insert --- modules/documentCanvas/documentCanvas.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index 4e61b88..1577be0 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -91,14 +91,17 @@ return function(sandbox) { //TODO: Insert inline var anchor = $(window.getSelection().anchorNode); var anchorOffset = window.getSelection().anchorOffset; - if(anchor[0].nodeType === Node.TEXT_NODE) + var textLen; + if(anchor[0].nodeType === Node.TEXT_NODE) { + textLen = anchor.text().length; anchor = anchor.parent(); + } if(anchor.text() === '') { var todel = anchor; anchor = anchor.parent(); todel.remove(); } - if(anchorOffset > 0 && anchorOffset < anchor.text().length) { + if(anchorOffset > 0 && anchorOffset < textLen) { if(wlxmlTag === null && wlxmlClass === null) { return this.splitWithNewNode(anchor); } -- 2.20.1