DocsAPI Initialization Script with Customizable Configuration Options

Answered using ChatGPT 4o by ChatGPT4o

Question:

/*!

;(function(DocsAPI, window, document, undefined) {

/*

    # Full #

    config = {
        type: 'desktop or mobile or embedded',
        width: '100% by default',
        height: '100% by default',
        documentType: 'word' | 'cell' | 'slide' | 'pdf' ,// deprecate 'text' | 'spreadsheet' | 'presentation',
        token: <string> encrypted signature
        document: {
            title: 'document title',
            url: 'document url'
            fileType: 'document file type',
            options: <advanced options>,
            key: 'key',
            vkey: 'vkey',
            referenceData: 'data for external paste',
            info: {
                owner: 'owner name',
                folder: 'path to document',
                uploaded: '<uploaded date>',
Answer:
                    sharingSettings: {
                        permissions: 'read' | 'write' | 'comment',
                        sharedWith: ['user1', 'user2', ...]
                    }
                },
                permissions: {
                    edit: true | false,
                    download: true | false,
                    print: true | false,
                    review: true | false,
                    comment: true | false,
                    fillForms: true | false,
                    modifyFilter: true | false,
                    modifyContentControl: true | false,
                    copy: true | false,
                    deleteCommentAuthorOnly: true | false,
                    rename: true | false
                },
                user: {
                    id: 'user id',
                    name: 'user name',
                    group: 'user group',
                    avatarUrl: 'user avatar url',
                    color: 'user color'
                },
                customization: {
                    logo: {
                        image: 'logo image url',
                        imageEmbedded: 'base64 encoded image',
                        url: 'logo link url'
                    },
                    feedback: {
                        url: 'feedback link url',
                        visible: true | false
                    },
                    goback: {
                        url: 'go back link url',
                        visible: true | false
                    },
                    about: {
                        visible: true | false
                    },
                    comments: {
                        visible: true | false
                    },
                    chat: {
                        visible: true | false
                    },
                    help: {
                        visible: true | false
                    },
                    toolbar: {
                        hideFileName: true | false,
                        hideSaveButton: true | false,
                        hidePrintButton: true | false,
                        hideDownloadButton: true | false,
                        hideChatButton: true | false,
                        hideCommentsButton: true | false,
                        hideHelpButton: true | false,
                        hideAboutButton: true | false
                    }
                }
            }
        };

        DocsAPI.init(config);

    })(window.DocsAPI, window, document);

This script initializes the DocsAPI with a configuration object that includes various settings for the document editor. The configuration object can be customized to fit different use cases, such as desktop, mobile, or embedded environments. It includes settings for document type, permissions, user information, and UI customization options. The DocsAPI.init(config) function is called to initialize the document editor with the