From e51396f5e4a7b44b55bd5e9806c296b85b44a1d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 25 Jul 2014 11:16:10 +0200 Subject: [PATCH 1/1] editor: fix - bring back ability to select elements without text --- src/editor/modules/documentCanvas/canvas/canvas.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 08df11f..2f25cb3 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -163,13 +163,20 @@ $.extend(Canvas.prototype, Backbone.Events, { }); this.rootWrapper.on('click', '[document-node-element], [document-text-element]', function(e) { - var position; + var position, element; e.stopPropagation(); if(e.originalEvent.detail === 3) { e.preventDefault(); canvas._moveCaretToTextElement(canvas.getDocumentElement(e.currentTarget), 'whole'); } else { if(mouseDown === e.target) { + element = canvas.getDocumentElement(e.target); + if(element && element.wlxmlNode.nodeType === Node.ELEMENT_NODE) { + if(element.getVerticallyFirstTextElement && !element.getVerticallyFirstTextElement({considerChildren: false})) { + canvas.setCurrentElement(element); + return; + } + } if(window.getSelection().isCollapsed) { position = utils.caretPositionFromPoint(e.clientX, e.clientY); canvas.setCurrentElement(canvas.getDocumentElement(position.textNode), {caretTo: position.offset}); -- 2.20.1