From: Aleksander Ɓukasz Date: Fri, 25 Jul 2014 09:16:10 +0000 (+0200) Subject: editor: fix - bring back ability to select elements without text X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/e51396f5e4a7b44b55bd5e9806c296b85b44a1d1?ds=sidebyside;hp=2d4b18135a37d60f45c008271dbbd5c038bd76d1 editor: fix - bring back ability to select elements without text --- 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});