X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a8dddd8aadd5c5c56c7a91d833bc770b42d0ccdc..8244aae227025150a77d6377caa52e0b7b0b5cbc:/src/editor/modules/documentCanvas/canvas/canvas.js diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index f8e9927..663b8a6 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -89,9 +89,21 @@ $.extend(Canvas.prototype, { keyboard.handleKey(e, this); }.bind(this)); + var mouseDown; + this.wrapper.on('mousedown', '[document-node-element], [document-text-element]', function(e) { + mouseDown = e.target; + }); + this.wrapper.on('click', '[document-node-element], [document-text-element]', function(e) { e.stopPropagation(); - canvas.setCurrentElement(canvas.getDocumentElement(e.currentTarget), {caretTo: false}); + if(e.originalEvent.detail === 3) { + e.preventDefault(); + canvas._moveCaretToTextElement(canvas.getDocumentElement(e.currentTarget), 'whole'); + } else { + if(mouseDown === e.target) { + canvas.setCurrentElement(canvas.getDocumentElement(e.currentTarget), {caretTo: false}); + } + } }); this.wrapper.on('paste', function(e) { @@ -131,7 +143,6 @@ $.extend(Canvas.prototype, { canvas._moveCaretToTextElement(canvas.getDocumentElement(mutation.target), 'end'); } observer.observe(canvas.wrapper[0], config); - canvas.publisher('contentChanged'); var textElement = canvas.getDocumentElement(mutation.target), toSet = mutation.target.data !== utils.unicode.ZWS ? mutation.target.data : ''; @@ -245,7 +256,6 @@ $.extend(Canvas.prototype, { } else { this.wrapper.find('.current-node-element').removeClass('current-node-element'); element._container().addClass('current-node-element'); - this.publisher('currentElementChanged', element); } }.bind(this); @@ -289,12 +299,13 @@ $.extend(Canvas.prototype, { range.setStart(node, where); } - var collapseArg = true; - if(where === 'end') { - collapseArg = false; + if(where !== 'whole') { + var collapseArg = true; + if(where === 'end') { + collapseArg = false; + } + range.collapse(collapseArg); } - range.collapse(collapseArg); - var selection = document.getSelection(); selection.removeAllRanges();