Fix "Uncaught (in promise) Error: window.getSelection() is null" error (#316)
* Fix "Uncaught (in promise) Error: window.getSelection() is null" error
This commit is contained in:
parent
3363fc90a3
commit
45f83116f6
|
@ -86,7 +86,7 @@ const getSelectedText = () => {
|
|||
const isInTextField = element.tagName === "INPUT" || element.tagName === "TEXTAREA";
|
||||
const selectedText = isInTextField
|
||||
? element.value.substring(element.selectionStart, element.selectionEnd)
|
||||
: window.getSelection().toString();
|
||||
: window.getSelection()?.toString() ?? "";
|
||||
return selectedText;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue