Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active March 27, 2023 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/10b1617d6cc9b034b666207049431eac to your computer and use it in GitHub Desktop.
Save bjoerntx/10b1617d6cc9b034b666207049431eac to your computer and use it in GitHub Desktop.
var serviceURL = "ChatGPT/RequestAPI";
TXTextControl.inputPosition.getTextPosition(function(pos) {
TXTextControl.paragraphs.getItemAtTextPosition(pos, function(par) {
par.getText(function(content) {
$.ajax({
type: "POST",
url: serviceURL,
contentType: "application/json",
data: JSON.stringify({
text: content,
type: requestedType
}),
success: successFunc,
error: errorFunc
});
function successFunc(data) {
$("#chatgpt-spinner").css({display: "none"});
par.select(function() {
TXTextControl.selection.setText(data);
})
}
function errorFunc(data) {
console.log(data);
$("#chatgpt-spinner").css({display: "none"});
}
})
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment