'codemirror - get the current word under the cursor

Is there a way to get the current text under the cursor? I don't mean the text of the entire line, but just the single word.. For example, if the cursor is actually in the middle of the word "orange" --> ora|nge, I need to get the word "orange".

Any way to solve this is much appreciated, thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source