Hello!
Im using the <script type="text/javascript" src="http://localhost/web-apps/apps/api/documents/api.js"></script>
to create document editor in web page and i want to insert text via the api method, but i’m getting this error when i try to access Api object : “Api is not defined” this is the code snippet: const oDocument = Api.GetDocument() const oParagraph = Api.CreateParagraph() oParagraph.AddText('Hello world!') oDocument.InsertContent([oParagraph])
Hello @MehdiDi
Are you trying to execute this snippet from browser console?
In general, please take a look at these two articles about macros and plugins in case you want to use your sample inside the editor:
https://api.onlyoffice.com/plugin/macros
https://api.onlyoffice.com/plugin/basic
Additionally, take a look at connector
class that allows you to interact with editors from outside:
https://api.onlyoffice.com/editors/connector
Please note that the connector is available only for ONLYOFFICE Developer Edition.