post selectText message

This commit is contained in:
rlx 2019-01-25 11:53:56 +05:30
parent ebab25c47d
commit b4434ec404
1 changed files with 8 additions and 0 deletions

View File

@ -345,6 +345,7 @@ txtjs.renderText = function(text) {
html = text.replace(/</g, '&lt;').replace(/>/g, '&gt;')
html = html.replace().replace(/\r\n/g, '\n').replace(/[\r\n]/g, '<br>')
txtjs.html = Ox.encodeHTMLEntities(text).replace(/\r\n/g, '\n').replace(/[\r\n]/g, '<br>')
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