Page 1 of 1

Inserting a table with pure JavaScript (not a plugin)

PostPosted: Thu Dec 07, 2017 2:03 am
by John at O5
Greetings,

I am using Integration Edition to put OnlyOffice Word editor on my site.

I have a button that needs to inject a table into the document.

Here is the code that my button executes:

Code: Select all
var Api = new window.Asc.asc_docs_api(); // This line does not work. How can I get access to the Api for inserting content?

var oDocument = Api.GetDocument();
var oTable, oCell;
oDocument.CreateNewHistoryPoint();
oTable = Api.CreateTable(2, 2);
oTable.GetRow(0).GetCell(0).GetContent().GetElement(0).AddText("A");
oTable.GetRow(0).GetCell(1).GetContent().GetElement(0).AddText("B");
oTable.GetRow(1).GetCell(0).GetContent().GetElement(0).AddText("a1");
oTable.GetRow(1).GetCell(1).GetContent().GetElement(0).AddText("b1");
oDocument.Push(oTable);


The first line fails, so I am not able to get access to the Api.

How can I get access to the Api to inject this table?

Thanks for your help!
-John

Re: Inserting a table with pure JavaScript (not a plugin)

PostPosted: Thu Dec 07, 2017 7:00 pm
by robertotomas
Api is exposed from within plugins .. so you can do that in a plugin.

It is important to remember that there is an outer iframe that only office loads into, it isn't exposed in your app/component at all. :)