Compare commits
No commits in common. "a71ffdb82fbc449ad6fe8b46f164c601d52b701e" and "dfe28225587623ab7db161540ac1d269e34922f6" have entirely different histories.
a71ffdb82f
...
dfe2822558
1 changed files with 16 additions and 16 deletions
|
@ -2,7 +2,17 @@ let txtjs = {}
|
|||
|
||||
Ox.load({UI: {loadCSS: false}}, function() {
|
||||
Ox.$parent.bindMessage(function(data, event) {
|
||||
txtjs.onMessage(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)
|
||||
})
|
||||
} else if (event == 'removeAnnotation') {
|
||||
txtjs.selectNote(data.id)
|
||||
txtjs.removeNote()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -124,7 +134,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 = {
|
||||
|
@ -170,7 +180,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) {
|
||||
|
@ -217,18 +227,8 @@ txtjs.noteExists = function(note) {
|
|||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
} else if (event == 'removeAnnotation') {
|
||||
txtjs.selectNote(data.id)
|
||||
txtjs.removeNote()
|
||||
}
|
||||
txtjs.onMessage = function(action, data) {
|
||||
|
||||
}
|
||||
|
||||
txtjs.postMessage = function(action, data) {
|
||||
|
@ -256,7 +256,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']
|
||||
|
|
Loading…
Reference in a new issue