Created
April 6, 2020 10:20
-
-
Save bjoerntx/a07cf732e668cb3f806fd6e684f665d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function addComment() { | |
var id = Math.random().toString(36).substring(2); // random id | |
var userName = await getUserNames(); | |
// create comment object | |
var comment = { | |
comment: "", | |
author: userName, | |
timestamp: Date.now(), | |
id: id, | |
}; | |
var range = await getSelectionRange(); | |
TXTextControl.select(range.start, 0); | |
// insert start target | |
TXTextControl.documentTargets.add("txcs_" + id, dt => { | |
dt.setName(JSON.stringify(comment)); | |
dt.setDeleteable(false); | |
TXTextControl.select(range.end, 0); | |
// insert end target | |
TXTextControl.documentTargets.add("txce_" + id, endTarget => { | |
_activeComment = id; | |
refreshComments(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment