Created
April 1, 2024 18:47
-
-
Save bjoerntx/3f80cd869bc32d425067cc88b2a50cae 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
// 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