editor.getSelectedText() no longer returns entire draft text by default

Did editor.getSelectedText() behavior change earlier this year?

It used to return the whole draft if there was no current selection.

In March or Feb, it stopped working that way - see conversation at https://forums.getdrafts.com/t/mermaid-diagram/7031

A function that returns all or selected text would be appreciated -


editor.getSelectedText() has never behaved that way, and shouldn’t. That’s not what you would typically want from a function like that. Here’s two alternatives:

// selection tag works that way...
let s = draft.processTemplate("[[selection]]");

// or
let s = editor.getSelectedRange()[1] > 0 ? editor.getSelectedText() : editor.getText();