From b4434ec404731742111ad1dbbb2eb8c748f891b4 Mon Sep 17 00:00:00 2001 From: rlx Date: Fri, 25 Jan 2019 11:53:56 +0530 Subject: [PATCH] post selectText message --- txt.js/txt.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/txt.js/txt.js b/txt.js/txt.js index 7a5a455..badfd95 100644 --- a/txt.js/txt.js +++ b/txt.js/txt.js @@ -345,6 +345,7 @@ txtjs.renderText = function(text) { html = text.replace(//g, '>') html = html.replace().replace(/\r\n/g, '\n').replace(/[\r\n]/g, '
') txtjs.html = Ox.encodeHTMLEntities(text).replace(/\r\n/g, '\n').replace(/[\r\n]/g, '
') + window.addEventListener('mouseup', onMouseup) window.addEventListener('resize', onResize) window.addEventListener('scroll', onScroll) document.addEventListener('keydown', function(e) { @@ -418,6 +419,13 @@ txtjs.renderText = function(text) { txtjs.renderSVGs() let factor, margin onResize() + function onMouseup() { + let note = txtjs.getNoteFromSelection() + if (!note || txtjs.noteExists(note)) { + txtjs.postMessage('selectText', null) + } + txtjs.postMessage('selectText', note) + } function onResize() { factor = scrollTextElement.clientHeight / textElement.clientHeight margin = textElement.offsetWidth * 0.1