Methods

After initializing document editor you will get the object that can be used to call the methods.

var docEditor = new DocsAPI.DocEditor("placeholder", config);
  • denyEditingRights - deny editing. This method can be called when you want to make the document editing unavailable.

    docEditor.denyEditingRights(message);
    
    Parameter Description Type Presence
    message Defines the text messages for dialog. string optional
  • destroyEditor - destroy docEditor object. This method can be called when you want to reinit document editor with another configurations. Used since version 4.3.

    docEditor.destroyEditor();
    
  • downloadAs - download the edited file. This method can be called only when the existence of the onDownloadAs events. Document editing service asynchronously creates a document and triggers the onDownloadAs event with a link in parameter.

    docEditor.downloadAs();
    
  • refreshHistory - show the document version history. This method must be called after the onRequestHistory events.

    docEditor.refreshHistory({
        "currentVersion": 2,
        "history": [
            {
                "changes": changes, //the changes from the history object returned after saving the document
                "created": "2010-07-06 10:13 AM",
                "key": "af86C7e71Ca8",
                "serverVersion": serverVersion, //the serverVersion from the history object returned after saving the document
                "user": {
                    "id": "F89d8069ba2b",
                    "name": "Kate Cage"
                },
                "version": 1
            },
            {
                "changes": changes,
                "created": "2010-07-07 3:46 PM",
                "key": "Khirz6zTPdfd7",
                "serverVersion": serverVersion,
                "user": {
                    "id": "78e1e841",
                    "name": "John Smith"
                },
                "version": 2
            },
            ...
        ],
    });
    

    Show the error message explaining why the version history can not be displayed.

    docEditor.refreshHistory({
        "error": "Exception",
    });
    
    Parameter Description Type Presence
    currentVersion Defines the current document version number. integer required
    error Defines the error message text. string optional
    history Defines the array with the document versions. array required
    history.changes Defines the changes from the history object returned after saving the document. object optional
    history.created Defines the document version creation date. string required
    history.key Defines the unique document identifier used for document recognition by the service. string required
    history.user Defines the user who is the author of the document version. object optional
    history.user.id Defines the identifier of the user who is the author of the document version. string optional
    history.user.name Defines the name of the user who is the author of the document version. string optional
    history.version Defines the document version number. integer required
  • setHistoryData - send the link to the document for viewing the version history. This method must be called after the onRequestHistoryData events.

    docEditor.setHistoryData({
        "key": "Khirz6zTPdfd7",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiJLaGlyejZ6VFBkZmQ3IiwidXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3giLCJ2ZXJzaW9uIjoyfQ.N9N9IMwX5e6kdfx4wssAPrGMnzPAZCd4PwDf2D8mJ8s",
        "url": "http://example.com/url-to-example-document.docx",
        "version": 2
    });
    

    Where the example.com is the name of the the server where document manager and document storage service are installed. See the How it works section to find out more on Document Server service client-server interactions.

    If after editing and saving the document the link changesurl to the file with changes data is returned, download the file by this link and send the file url in changesUrl parameter. The url address of the document previous version must be sent in previous.url parameter.

    docEditor.setHistoryData({
        "changesUrl": "http://example.com/url-to-changes.zip",
        "key": "Khirz6zTPdfd7",
        "previous": {
            "key": "af86C7e71Ca8",
            "url": "http://example.com/url-to-the-previous-version-of-the-document.docx"
        },
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjaGFuZ2VzVXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3VybC10by1jaGFuZ2VzLnppcCIsImtleSI6IktoaXJ6NnpUUGRmZDciLCJwcmV2aW91cyI6eyJrZXkiOiJhZjg2QzdlNzFDYTgiLCJ1cmwiOiJodHRwOi8vZXhhbXBsZS5jb20vdXJsLXRvLXRoZS1wcmV2aW91cy12ZXJzaW9uLW9mLXRoZS1kb2N1bWVudC5kb2N4In0sInVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS91cmwtdG8tZXhhbXBsZS1kb2N1bWVudC5kb2N4IiwidmVyc2lvbiI6Mn0.9dgDsaVLFQ6RtoX_1s2pBVJHGnyMjxDXKC2TpC2nXb4",
        "url": "http://example.com/url-to-example-document.docx",
        "version": 2
    });
    

    Where the example.com is the name of the the server where document manager and document storage service are installed. See the How it works section to find out more on Document Server service client-server interactions.

    Send the error message explaining why the document version can not be displayed.

    docEditor.setHistoryData({
        "error": "Exception",
        "version": 2
    });
    
    Parameter Description Type Presence
    changesUrl Defines the url address of the file with the document changes data, which can be downloaded by the changesurl link from the JSON object returned after saving the document. string optional
    error Defines the error message text. string optional
    key Defines the document identifier used to unambiguously identify the document file. string required
    previous Defines the object of the previous version of the document if changesUrl address was returned after saving the document. object optional
    previous.key Defines the document identifier of the previous version of the document. string required
    previous.url Defines the url address of the previous version of the document. string required
    token Defines the encrypted signature added to the parameter in the form of a token. string optional
    url Defines the url address of the current version of the document. Can be downloaded by the url link from the JSON object returned after saving the document. string required
    version Defines the document version number. integer required
  • showMessage - Display tooltip with the message. This method can be called only after the onReady events.

    docEditor.showMessage(message);
    
    Parameter Description Type Presence
    message Defines the message text. string required