Skip to content
On this page

React

安装

sh
npm install --save @onlyoffice/document-editor-react

or

sh
yarn add @onlyoffice/document-editor-react -S

使用示例

jsx
import { DocumentEditor } from "@onlyoffice/document-editor-react";
var onDocumentReady = function (event) {
    console.log("Document is loaded");
};

<DocumentEditor
  id="docxEditor"
  documentServerUrl="http://documentserver/"
  config={{
      "document": {
          "fileType": "docx",
      "key": "Khirz6zTPdfd7",
      "title": "Example Document Title.docx",
      "url": "https://example.com/url-to-example-document.docx"
    },
    "documentType": "word",
    "editorConfig": {
        "callbackUrl": "https://example.com/url-to-callback.ashx"
    }
  }}
  events_onDocumentReady={onDocumentReady} />

Props

名 称
类 型
默 认
必 填
描 述
idstringnulltrue组件唯一标识
documentServerUrlstringnulltrue文档服务器地址
configobjectnulltrue用于打开带有token的文件的通用配置对象
document_fileTypestringnullfalse文件类型
document_titlestringnullfalse文件名称
documentTypestringnullfalse文档类型
heightstringnullfalse窗口高度
typestringnullfalse终端类型 desktop, mobile, embedded
widthstringnullfalse窗口宽度
events_onAppReady(event: object) => voidnullfalse应用初始化
events_onDocumentStateChange(event: object) => voidnullfalse文档修改
events_onMetaChange(event: object) => voidnullfalse通过meta命令更改文档的元信息
events_onDocumentReady(event: object) => voidnullfalse文档加载
events_onInfo(event: object) => voidnullfalse应用程序打开了文件
events_onWarning(event: object) => voidnullfalse出现警告
events_onError(event: object) => voidnullfalse出现错误
events_onRequestSharingSettings(event: object) => voidnullfalse点击置管理文档访问权限
events_onRequestRename(event: object) => voidnullfalse点击重命名
events_onMakeActionLink(event: object) => voidnullfalse点击书签获取链接,定位书签
events_onRequestInsertImage(event: object) => voidnullfalse点击插入图片
events_onRequestSaveAs(event: object) => voidnullfalse点击另存为
events_onRequestMailMergeRecipients(event: object) => voidnullfalse点击选择收件人数据
events_onRequestCompareFile(event: object) => voidnullfalse点击文档比对
events_onRequestEditRights(event: object) => voidnullfalse点击编辑按钮
events_onRequestHistory(event: object) => voidnullfalse点击历史版本
events_onRequestHistoryClose(event: object) => voidnullfalse关闭历史版本
events_onRequestHistoryData(event: object) => voidnullfalse点击特定版本
events_onRequestRestore(event: object) => voidnullfalse点击恢复版本按钮




如果有帮助到您,请作者喝杯咖啡吧