OFFICE-onlyoffice

onlyoffice简介
onlyoffice是一个在线创建,编辑和协作文档服务
使用方法

1.给编辑器添加一个div占位空间,其中将传递有关编辑器参数的所有信息:

< div  id = “placeholder” > </ div > 
< script  type = “text / javascript”  
  src = “http://documentserver/web-apps/apps/api/documents/api.js” >
</ script >

2.创建docEditor:

var docEditor = new DocsAPI.DocEditor(“placeholder”,config);

3.其中config是一个对象,全部属性配置如下:

       # Full #

        config = {
            type: 'desktop or mobile',
            width: '100% by default',
            height: '100% by default',
            documentType: 'text' | 'spreadsheet' | 'presentation',
            document: {
                title: 'document title',
                url: 'document url'
                fileType: 'document file type',
                options: <advanced options>,
                key: 'key',
                vkey: 'vkey',
                info: {
                    author: 'author name',
                    folder: 'path to document',
                    created: '<creation date>',
                    sharingSettings: [
                        {
                            user: 'user name',
                            permissions: '<permissions>',
                            isLink: false
                        },
                        ...
                    ]
                },
                permissions: {
                    edit: <can edit>, // default = true
                    download: <can download>, // default = true
                    reader: <can view in readable mode>,
                    review: <can review>, // default = edit
                    print: <can print>, // default = true
                    rename: <can rename>, // default = false
                    changeHistory: <can change history>, // default = false
                    comment: <can comment in view mode> // default = edit
                }
            },
            editorConfig: {
                mode: 'view or edit',
                lang: <language code>,
                location: <location>,
                canCoAuthoring: <can coauthoring documents>,
                canBackToFolder: <can return to folder> - deprecated. use "customization.goback" parameter,
                createUrl: 'create document url', 
                sharingSettingsUrl: 'document sharing settings url',
                fileChoiceUrl: 'mail merge sources url',
                callbackUrl: <url for connection between sdk and portal>,
                mergeFolderUrl: 'folder for saving merged file',
                licenseUrl: <url for license>,
                customerId: <customer id>,

                user: {
                    id: 'user id',
                    name: 'user name'
                },
                recent: [
                    {
                        title: 'document title',
                        url: 'document url',
                        folder: 'path to document'
                    },
                    ...
                ],
                templates: [
                    {
                        name: 'template name',
                        icon: 'template icon url',
                        url: 'http://...'
                    },
                    ...
                ],
                customization: {
                    logo: {
                        image: url,
                        imageEmbedded: url,
                        url: http://...
                    },
                    backgroundColor: 'header background color',
                    textColor: 'header text color',
                    customer: {
                        name: 'SuperPuper',
                        address: 'New-York, 125f-25',
                        mail: 'support@gmail.com',
                        www: 'www.superpuper.com',
                        info: 'Some info',
                        logo: ''
                    },
                    about: true,
                    feedback: {
                        visible: false,
                        url: http://...
                    },
                    goback: {
                        url: 'http://...',
                        text: 'Go to London'
                    },
                    chat: true,
                    comments: true,
                    zoom: 100,
                    compactToolbar: false,
                    leftMenu: true,
                    rightMenu: true,
                    toolbar: true,
                    header: true,
                    statusBar: true,
                    autosave: true,
                    forcesave: false,
                    commentAuthorOnly: false,
                    showReviewChanges: false
                },
                plugins: {
                    autoStartGuid: 'asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}',
                    url: '../../../../sdkjs-plugins/',
                    pluginsData: [
                        "helloworld/config.json",
                        "chess/config.json",
                        "speech/config.json",
                        "clipart/config.json",
                    ]
                }
            },
            events: {
                'onReady': <application ready callback>, // deprecated
                'onAppReady': <application ready callback>,
                'onBack': <back to folder callback>,
                'onDocumentStateChange': <document state changed callback>
                'onDocumentReady': <document ready callback>
            }
        }

        # Embedded #

        config = {
            type: 'embedded',
            width: '100% by default',
            height: '100% by default',
            documentType: 'text' | 'spreadsheet' | 'presentation',
            document: {
                title: 'document title',
                url: 'document url',
                fileType: 'document file type',
                key: 'key',
                vkey: 'vkey'
            },
            editorConfig: {
                licenseUrl: <url for license>,
                customerId: <customer id>,
                autostart: 'document',    // action for app's autostart. for presentations default value is 'player'
                embedded: {
                     embedUrl: 'url',
                     fullscreenUrl: 'url',
                     saveUrl: 'url',
                     shareUrl: 'url',
                     toolbarDocked: 'top or bottom'
                }
            },
            events: {
                'onReady': <application ready callback>, // deprecated
                'onAppReady': <application ready callback>,
                'onBack': <back to folder callback>,
                'onError': <error callback>,
                'onDocumentReady': <document ready callback>
            }
        }

4.下面是我写的示例代码:

<!DOCTYPE>
<html>
<head>
    <meta charset="UTF-8">
    <script  type = "text/javascript"  src = "http://192.168.41.138/web-apps/apps/api/documents/api.js"></script>
    <script type="text/javascript">
        function f() {
            var docEditor=new DocsAPI.DocEditor("placeholder", {
                document: {
                    fileType: "docx",
                    key: "fileKey",
                    title: "test.xlsx",
                    url: "http://192.168.43.195:8080/radosgw/doc/test.docx"
                },
                documentType: "text",
                editorConfig: {
                    lang:"zh-CN",
                    callbackUrl:"http://192.168.43.195:8080/radosgw/office/callbackUrl",
                    mode:"edit",
                    user: {
                        id: "userId",
                        name: "user1"
                    }
                }
            });
        }

    </script>
</head>
<body onload="f()">
<div>
    <div  id = "placeholder"> </div>
</div>
</body>
</html>        
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,010评论 19 139
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,148评论 1 32
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,974评论 6 342
  • 我,一个不漂亮,家境背景一般的大山里出来的女孩,全身上下只有身材勉强过得去,不折不扣的不修边幅的女汉子,当我深陷爱...
    本尊主阅读 228评论 0 0
  • 中国股市为什么这么烂 阿雷曾经指出中国股市其实是世界上最差的股市。这是因为中国股市有以下的十大缺陷: 第一,中国股...
    彭斐导阅读 2,253评论 0 0