Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created April 1, 2024 18:47
Show Gist options
  • Save bjoerntx/3f80cd869bc32d425067cc88b2a50cae to your computer and use it in GitHub Desktop.
Save bjoerntx/3f80cd869bc32d425067cc88b2a50cae to your computer and use it in GitHub Desktop.
// Enable commands for TXTextControl
TXTextControl.enableCommands();
// Add event listeners for comment changes and deletions
TXTextControl.addEventListener("commentChanged", preventComment);
TXTextControl.addEventListener("commentDeleted", preventComment);
// Function to prevent comment changes from other authors
function preventComment(comment) {
TXTextControl.getUserNames(userNames => {
if (comment.commentedText.userName !== userNames[0]) {
TXTextControl.undo(() => {
TXTextControl.sendCommand(TXTextControl.Command.CommentsViewerRefresh);
alert("Comments from other authors cannot be changed!");
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment