I am trying to build a google doc add-on that capitalize the selected text by the user, but the first step i am trying to do is to log the selected text to the console.
Can someone help in this?
I wrote this in the client side (html):
$(document).ready(function() {
$('#selectionButton').click(function() {
var selectedText = window.getSelection().toString();
console.log("Selected Text:", selectedText);
});
});
And this in the server-side:
function getSelection() {
var selection = DocumentApp.getActiveDocument().getSelection();
var selectedText = selection.getRangeElements()[0].getElement().asText().getText();
// Log the selected text to the console
console.log("Selected Text:", selectedText);
}
But I am getting nothing!