I want to insert a word in the current position of the mouse, and then set the inserted word as a bookmark,Here’s how I did it:

const insert = () => {
const connector = docEditorde.value.createConnector();
connector.callCommand(() => {
const oDocument = Api.GetDocument();;
const oParagraph = Api.CreateParagraph();
var oRange = oParagraph.GetRange(0, 7);
}, true);

But there are problems with that:

How do I solve this problem, or is there another way to insert a word at the current position of the mouse cursor and set it as a bookmark

Document Server version:
Type of installation of the Document Server (docker, deb/rpm, exe)

Hello @wind

First of all, as I can see, you are using Automation API to achieve the result. In case you have active or trial Developer license, you can consider contacting us via Helpdesk platform to get prompt replies.

As for the scenario that you are trying to run through: there are several mistakes in the snippet that you’ve provided but also there is easier way to make it done. You can simply use InsertAndReplaceContentControls method to insert Content Control with predefined content and add bookmark on it right away. The fact that Content Control is placed right at the cursor position also comes in handy.
In combination with connector you can do it this way:

var arrDocuments = [{
    "Props": {
		"Id": 7,
		"Lock": 0"
	"Script": "var oParagraph = Api.CreateParagraph();oParagraph.AddText('Bookmark');Api.GetDocument().InsertContent([oParagraph]);var oRange = oParagraph.GetRange(0, 7);oRange.AddBookmark('PO_001');"
connector.executeMethod ("InsertAndReplaceContentControls", [arrDocuments]);

Here Script string defines all operations you’d like to perform inside Content Control. In your case it places text inside the box and adds bookmark on it independently from the rest of the document.

Please note that in this case data inside Content Control is isolated from the rest of the document when method is executed.