08.08.14, 15:24
I need help finding info about the selected text.
I tried this, but it it came up undefined.
var selectedItems = document.getItems({
selected: true
});
var range = selectedItems.characters;
any help is greatly appreciated
The property you're looking for is the selectedRange of a TextStory object. This returns a TextRange object, which contains the whole string as the .content property, and an array of characters which each have a single character as their content.
var sel=document.selectedItems[0];
var range=sel.selectedRange;
console.log("this is the selected string:");
console.log(range.content);
console.log("this is the first selected character:");
console.log(range.characters[0].content);