How to get current paragraph text, using GetCurrentSentence only returns before `.`

Hi @Alexandre ,

I’m working with the OnlyOffice editor and using the GetCurrentSentence method from the plugin API. However, I’ve noticed a limitation in its behavior:

If I place the cursor after the last character of a sentence**, such as right after the period (.), GetCurrentSentence returns an empty string.

  • For example, in the sentence:
    "This is a sentence."
    If I place the cursor right after the period, it gives me nothing. But if I place it within the sentence, it returns "This is a sentence." as expected.

:question: What I’m trying to achieve:

I want to be able to extract the entire paragraph text or at least the current sentence, even when the cursor is placed at the end of the sentence or paragraph.

The main reason i require this is to identify the paragraph which user has its cursor on.

Hello @agamdev,
You can get paragraph’s text in general by using the following method:

var oDocument = Api.GetDocument();
let paragraph=oDocument.GetElement(1)
let result=paragraph.GetText({"Numbering": true, "Math": true, "NewLineSeparator": "\r", "TabSymbol": "\t"});
console.log(result)

If you want to specifically get current paragraph’s text, there are no such methods, but you can use this plugin method - GetSelectedText | ONLYOFFICE
Or put text in content controls and then use GetCurrentContentControl | ONLYOFFICE