sdkjs-plugins icon indicating copy to clipboard operation
sdkjs-plugins copied to clipboard

Is there any way to set bookmark text?

Open Riant opened this issue 3 years ago • 4 comments

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.

Riant avatar Aug 10 '21 11:08 Riant

@askonev Please take a look

ShockwaveNN avatar Aug 10 '21 11:08 ShockwaveNN

@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

askonev avatar Aug 13 '21 15:08 askonev

@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.

Riant avatar Aug 17 '21 10:08 Riant

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

askonev avatar Aug 18 '21 08:08 askonev