Get the current active style override values in DocBuilderScript

OnlyOffice Version: 5.6.5
Installation method: Self-Hosted
OS: Windows Version 10.0.19045 Build 19045 / Chrome Version 108.0.5359.125 (64-Bit)

Hi!

Our application uses custom plugins to enable users to insert text into the document. In simple cases, we just call AddText, in complex cases we build a longer script and use document.insertContent.

The problem is that we want to apply the currently used style when inserting content and thus need some way to get information on the current settings (ParaPr, TextPr) to apply them in our script as well. Just using normal add-Methods use the ‘normal’ style, even if it is not selected, which may be different or remains unchanged when only using the controls in the leftmost panel (font settings etc.)
So my question is: Is there any way to get:

  • The ParaPr and TextPr that are currently being used? (GetStyle() returns the ‘normal’ style instead)
  • Less helpful, but still better than nothing: The name of the currently active style?

Thank you kindly in advance.

Hello @tkap

First of all, please pay attention that you are using very old version of Document Builder, the actual version of Document Builder is 7.2. Keep in mind that many features may work incorrectly or not work completely in old versions.

As for the style methods: please visit this page to find all style-related methods that can be used in Document Builder:
https://api.onlyoffice.com/docbuilder/textdocumentapi/ApiStyle
Specifically, to get the style properties of the certain paragraph you can use GetParaPr method and to get the name of currently used style you can use GetName method.