Hi!
I have written a custom visual plugin which allows a user to click a link to insert an inline content control into docx documents.
In order to do this I insert an empty inline content control:
window.Asc.plugin.executeMethod("AddContentControl", [2, {"Lock" : 3}]);
Then in ‘onMethodReturn()’ I use InsertAndReplaceContentControls to insert my actual text into the empty inline cc, something like this:
obj.Props.InternalId = returnVal.InternalId;
window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [[obj]]);
Where “obj” is a document object with “Props.Inline” set to true and a Script block that actually some content into the document.
This works great - you get an inline content control with the appropriate content, but the cursor ends up inside the content control [it is editable], at the start of the inserted text.
I’d like instead for the cursor to be after the inserted CC, so the user can type and text will show up in the same paragraph but after the content control.
I’ve tried the following:
- I can shift it to the end of the content control via
executeMethod ("MoveCursorToContentControl", [ returnVal.InternalId, false]);
but this is still inside the CC so if the user types they’re typing within the content control. - I can select the entire content control via ‘executeMethod(“SelectContentControl”, [returnVal.InternalId]);’ - but that’s again not what I’d like.
- I can shift the cursor to the end of the entire document via MoveCursorToEnd - but regardless of whether I pass true or false in as the last argument I’m not able to shift the cursor within the document itself
I’m not seeing any other APIs that help with this - either methods available via plugin.executeMethod, or document builder commands available via callCommand that allow me to explicitly position the cursor after a particular element [the contents control I just inserted], but I’m guessing this must be possible?
Thanks for any help or insight!
Document Server version:
OO Docs Developer Edition
[Document editor version shows up as 7.0.0]
Installation method:
- Running an “onpremesis” type doc server installation [ONLYOFFICE Api Documentation - Adding plugins]
OS:
- MacOS, running the doc server via docker and serving the main webpage and plugin HTML from a separate Tomcat instance
Browser version:
- Chrome Version 99.0.4844.51 (Official Build) (x86_64)