DOMGet the selected textGet the selected textJavaScript versionconst getSelectedText = () => window.getSelection().toString();