From: Aleksander Ɓukasz Date: Thu, 23 Jan 2014 12:32:17 +0000 (+0100) Subject: editor: canvas cursor fix - handle node with Zero Width Space only correctly X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/a8dddd8aadd5c5c56c7a91d833bc770b42d0ccdc editor: canvas cursor fix - handle node with Zero Width Space only correctly --- diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 70c0f49..f8e9927 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -357,16 +357,16 @@ $.extend(Cursor.prototype, { return { element: anchorElement, offset: selection.anchorOffset, - offsetAtBeginning: selection.anchorOffset === 0, - offsetAtEnd: selection.anchorNode.data.length === selection.anchorOffset + offsetAtBeginning: selection.anchorOffset === 0 || anchorElement.getText() === '', + offsetAtEnd: selection.anchorNode.data.length === selection.anchorOffset || anchorElement.getText() === '' }; } if(which === 'focus') { return { element: focusElement, offset: selection.focusOffset, - offsetAtBeginning: selection.focusOffset === 0, - offsetAtEnd: selection.focusNode.data.length === selection.focusOffset + offsetAtBeginning: selection.focusOffset === 0 || focusElement.getText() === '', + offsetAtEnd: selection.focusNode.data.length === selection.focusOffset || focusElement.getText() === '', }; } @@ -414,8 +414,8 @@ $.extend(Cursor.prototype, { return { element: placeData.element, offset: placeData.offset, - offsetAtBeginning: placeData.offset === 0, - offsetAtEnd: nodeLen === placeData.offset + offsetAtBeginning: placeData.offset === 0 || focusElement.getText() === '', + offsetAtEnd: nodeLen === placeData.offset || focusElement.getText() === '' }; } });