79206113

Date: 2024-11-20 07:02:53
Score: 7 🚩
Natty: 5
Report link

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!

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (0.5): how can I
  • Blacklisted phrase (1): help me
  • RegEx Blacklisted phrase (3): Can someone help me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: Daksh Jain