this is not working in my typescript code I have tried to get the text but I don't get any text . I have coded like below :
const range = editor.model.document.selection.getFirstRange();
let selectedText =''
if (range) {
for (const item of range.getItems()) {
if (item.is("$text") && "data" in item) {
selectedText += (item as { data: string }).data;
}
}
console.log('selected text::::',selectedText);
}
here ,every time I am getting the empty string . Can someone help me here how can I get the selected text in ckEditor ? Thanks!