I set up the Docker image for document builder as it is defined in the docs (without the JWT token for creating the POC).
I am using React, but because I want to programatically edit the document (I want to dynamically add highlights and anotations) I decided to use the api.js script insted of the React component (DocumentEditor).
The document is loded successfully (is visible), but then I get an error that createConnector() does not exist. And after I checked I see that it is not present in the Docker’s api.js file, but I see that it is present here: https://api.docs.onlyoffice.com/web-apps/apps/api/documents/api.js
Why is there no createConnector or how can I achive dynamically editing of documents in react app?
Are you using the Community Edition Document Server? In this case the connector class won’t be available. It can only be used in a Developer Edition Document Server with a special license.
Thanks for the response.
Yes, it is most likely community edition.
Does the Developer Edition Document Server come with a docker image or is only as a Service?
And is there a free/trial option for it, I’d like to first set everything up and then buy a license if needed.
editorConfig: {
mode: 'edit',
// Other configurations...
}
then it works, but also all users can edit. Is there no other way to edit the document programatically from frontend?
I would at least like to hide the options to edit the documnet for users …
This is expected behavior as your function makes changes in the document, so when mode is set to view you cannot make any changes, but if it is edit, then you can and it works.
If I understand correctly, your goal is to run editors, make certain changes in the document, but leave it uneditable for users. As a workaround you can start your document in edit mode to execute your function and then use SetEditingRestrictions method to restrict editing. For instance:
var connector = docEditor.createConnector();
connector.callCommand(
function () {
const oDocument = Api.GetDocument()
const aSearch = oDocument.Search("RANDOM")
aSearch[0].SetBold(true)
},
function () {
console.log("callback command")
}
);
connector.executeMethod("SetEditingRestrictions", ["readOnly"]);
};
That way after initializing editors, you function will be executed and editing will be restricted.
By the way, if you have active trial of Docs Developer Edition, you can also contact via Zendesk to get prompt replies.