ONLYOFFICE / DocumentBuilder

ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
https://www.onlyoffice.com/document-builder.aspx
GNU Affero General Public License v3.0
111 stars 56 forks source link

How to add custom API for presentation to document builder? #128

Closed Kevin-Loeng closed 6 months ago

Kevin-Loeng commented 6 months ago

I want to add some custom presentation API , by modify the source codes of document builder sdkjs.

For example, add GetAllTables method to sdkjs/slide/apiBuilder.js. Then I build the sdk-all.js by grunt, and replace the original sdk-all.js in my server.

/**
 * Returns an array with all the table objects from the slide.
 * @typeofeditors ["CPE"]
 * @returns {ApiTable[]} 
 * */
ApiSlide.prototype.GetAllTables = function(){
    var apiTables = [];
    if (this.Slide)
    {
        var drawingObjects = this.Slide.getDrawingObjects();
        for (var nObject = 0; nObject < drawingObjects.length; nObject++)
        {
            if (drawingObjects[nObject] instanceof AscFormat.CGraphicFrame)
                apiTables.push(new ApiTable(drawingObjects[nObject]));
        }
    }

    return apiTables;
};

But it cause javaScript error, even can't load the ppt as before. screenshot

How can i add some custom API to document builder sdk?

I also try to read the codes. But can’t understand how these global variable like AscFormat import to context.

// global.js
var Asc;
var AscDFH;
var AscCH;
var AscFormat;
var AscFonts;
var AscCommon;
var AscCommonWord;
var AscCommonExcel;
var AscCommonSlide;
var AscBuilder;
var AscWord;
var AscMath;
var AscJsonConverter;
var AscCrypto;
var AscOForm;

Please tell me how to find the definition of these global variable. I want to know all the properties and methods of them.

DocumentBuilder version: 7.4.1

Operating system: Server: centOS 7.9.0 Client: macOS Chrome 124.0.6367.78