ONLYOFFICE / sdkjs-plugins

The add-ons for ONLYOFFICE Document Server and ONLYOFFICE Desktop Editors.
https://www.onlyoffice.com
Apache License 2.0
136 stars 134 forks source link

Is there any way to set bookmark text? #160

Open Riant opened 3 years ago

Riant commented 3 years ago

Do you want to request a feature or report a bug? Request a feature

I need to change the bookmark text, for now, I can get bookmark range from document like below, but there is not any way to change the range text.

oRange = oDocument.GetBookmarkRange("bookmark1");
oRange.AddText(' xxx', 'after'); // I only can do that, but can not do something like SetText('xxx');

Is there any other API can do slimier things?

Thanks.

ShockwaveNN commented 3 years ago

@askonev Please take a look

askonev commented 3 years ago

@Riant Hi! Created an enchancement #51952 in our private repository to extend bookmarking methods. But at the moment you can interact with the data for which the bookmark was created as a Range object to which all methods of the ApiRange class are applicable.

Possible solution to replace the data to which the bookmark references.

oDocument = Api.GetDocument(); 
oParagraph = oDocument.GetElement(0); 
oParagraph.AddText( "ONLYOFFICE Document Builder "); 
oRange = oDocument.GetRange(0, 9); 
oRange.AddBookmark("Bookmark");

oBookmarkRange = oDocument.GetBookmarkRange("Bookmark");
oBookmarkRange.Delete();

oRange = oDocument.GetRange(0, 0);
oRange.AddText('Api methods for ');
oRange.AddBookmark("Bookmark_2");

ver. 6.3.2.8

Riant commented 3 years ago

@askonev I need to use this api in plugin, so your solution does not make scene for a document which uploaded by user, because we can not get the deleted bookmark range, and it is not (0, 0) in most cases.

So we need a ApiRange method to do that.

Thanks.

askonev commented 3 years ago

@Riant, I understand you. At the moment, it remains only to wait for the decision of the developers.