position: in,out

This commit is contained in:
rlx 2019-02-01 12:40:45 +05:30
parent e1937f3c7c
commit 99b88de8c4
1 changed files with 13 additions and 13 deletions

View File

@ -2,14 +2,7 @@ let txtjs = {}
Ox.load({UI: {loadCSS: false}}, function() {
Ox.$parent.bindMessage(function(data, event) {
if (event == 'selectAnnotation') {
txtjs.selectNote(data.id)
} else if (event == 'addAnnotations') {
data.annotations.forEach(function(note) {
txtjs.renderNote(note)
txtjs.notes.push(note)
})
}
txtjs.onMessage(data, event)
})
})
@ -131,7 +124,7 @@ txtjs.getNoteFromSelection = function() {
return
}
let position = txtjs.getPosition(range)
let pos = position.split(':').map(function(v) {
let pos = position.split(',').map(function(v) {
return parseInt(v)
})
let note = {
@ -177,7 +170,7 @@ txtjs.getPosition = function(range) {
while (' \n'.includes(txtjs.text.substr(end - 1, 1))) {
end--
}
return start + ':' + end
return start + ',' + end
}
txtjs.getRange = function(id, start, end) {
@ -224,8 +217,15 @@ txtjs.noteExists = function(note) {
})
}
txtjs.onMessage = function(action, data) {
txtjs.onMessage = function(data, event) {
if (event == 'selectAnnotation') {
txtjs.selectNote(data.id)
} else if (event == 'addAnnotations') {
data.annotations.forEach(function(note) {
txtjs.renderNote(note)
txtjs.notes.push(note)
})
}
}
txtjs.postMessage = function(action, data) {
@ -253,7 +253,7 @@ txtjs.removeNote = function() {
}
txtjs.renderNote = function(note) {
let pos = note.position.split(':').map(function(v) {
let pos = note.position.split(',').map(function(v) {
return parseInt(v)
})
let ids = ['txt', 'txt-scroll']