OnlyOffice configuration document

OnlyOffice configuration parameter document

For more information, please visit the official documentation
https://api.onlyoffice.com/editors/basic

1. Basic parameters

parameter name type describe example
documentType string Define the type of document to open:
word - document (.doc, .docm, .docx, .docxf, .dot, .dotm, .dotx, .epub, .fodt, .fb2, .htm, .html, .mht, .odt, .oform, .ott, .oxps, .pdf, .rtf, .txt, .djvu, .xml, .xps),
cell - table (.csv, .fods, .ods, .ots, .xls, .xlsb, .xlsm, .xlsx, .xlt, .xltm, .xltx),
slide (.fodp, .odp, .otp, .pot, .potm, .potx, .pps, .ppsm, .ppsx , .ppt, .pptm, .pptx).
text , spreadsheet and presentation are deprecated starting from version 6.1. Please use the new value instead.
“word”
height string Defines the document height in the browser window (default is 100%). “100%”
width string Defines the document width in the browser window (default is 100%). “100%”
token string Defines a cryptographic signature in the form of a token that is added to the document server configuration. “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M”
type string Defines the platform type used to access the document. Can be: Optimized for accessing documents from a desktop or laptop - Desktop, Optimized for accessing documents from a tablet or smartphone - Mobile, Specifically designed for easy embedding into web pages - Embedded. The default value is "desktop". “desktop”

2. Advanced parameters

(1) document object
parameter name type describe example
fileType* string Defines the file type of the source viewing or editing document. Must be lowercase. The following file types are available:
.csv, .djvu, .doc, .docm, .docx, .docxf, .dot, .dotm, .dotx, .epub, .fb2, .fodp, .fods, .fodt, .htm, .html, .mht, .odp, .ods, .odt, .oform, .otp, .ots, .ott, .oxps, .pdf, .pot, .potm, .potx, .pps, .ppsm, .ppsx , .ppt, .pptm, .pptx, .rtf, .txt, .xls, .xlsb, .xlsm, .xlsx, .xlt, .xltm, .xltx, .xml, .xps .
“docx”
key* string Defines the unique document identifier used by the service to identify the document. If a known key is sent, the document will be fetched from cache. The key must be regenerated each time the document is edited and saved. Document URLs can be used as keywords, but no special characters are used and the length is limited to 128 symbols. “Khirz6zTPdfd7”
referenceData object The fileKey
service is used to obtain a unique document identifier for a file link. Must not be changed when editing and saving the document (not equal to the document.key parameter) Type: String, for example: "BCFA2CED";
instanceId
A unique system identifier. If data is copied from a file on one system and inserted into a file on another system, Paste via link will not be available and there will be no corresponding button in the context menu, Type: String, Example: "https://example .com".
title* string Defines the desired filename of the document being viewed or edited, which will also be used as the filename when downloading the document. The length is limited to 128 symbols.
在这里插入图片描述
“Example Document Title.docx”
url* string Defines the absolute URL of the storage source to view or edit the document. Make sure to add the token when using local links. Otherwise, an error will occur. “http://localhost:6666/doc/666.docx”
info object
parameter name type describe example
author string Defines the name of the document author/creator. Deprecated since version 5.4, please use owner instead “John Smith”
created string Defines the document creation date. Deprecated since version 5.4, please use uploaded instead. “2010-07-07 3:46 PM”
favorite boolean Defines the highlight state of the favorite icon. When the user clicks on the icon, the onMetaChange event is called. If the parameter is undefined, the Favorites icon will not be displayed in the editor window title. true
folder string Defines the folder where the document is stored (can be empty if the document is stored in the root folder). “Example Files”
owner string Defines the name of the document owner/creator. “John Smith”
sharingSettings Array 显示有关允许与其他用户共享文档的设置的信息:
isLink
将用户图标更改为链接图标,类型:boolean
permissions
具有上述名称的用户的访问权限。可以是Full Access, Read Only 或者 Deny Access。类型:string,例子:‘Full Access’
user
文档将与之共享的用户的名称,类型:string,例子:‘John Smith’
uploaded string 定义文档上传日期 “2010-07-07 3:46 PM”
permissions对象
参数名称 类型 描述 例子
changeHistory boolean 允许在使用onRequestRestore事件时显示还原按钮。默认值为false。自版本5.5以来已弃用,请添加onRequestRestore字段代替 true
chat boolean 定义是否在文档中启用聊天功能。如果聊天权限设置为true,将显示聊天菜单按钮。默认值为true。 true
comment boolean 定义是否可以对文档进行注释。如果comment设置为“true”,文档侧栏将包含注释菜单选项;如果mode参数设置为edit,文档注释将仅对文档编辑器可用。默认值与edit参数的值一致。
如果edit设置为“true”,而comment也设置为“true”,则用户将能够编辑文档和注释。如果edit设置为“true”,comment设置为“false”,则用户将只能编辑,相应的注释功能将仅可查看,注释的添加和编辑将不可用。如果edit设置为“false”,comment设置为“true”,则文档将仅可用于注释。如果edit设置为“false”,review设置为“false”,注释设置为“true”,则不考虑fillForms的值,并且无法填写表单
true
commentGroups object 定义用户可以编辑、删除和/或查看其注释的组。该对象具有以下参数:
edit
用户可以编辑由其他用户作出的评论,类型:array,例子: [“Group2”, “”];
remove
用户可以删除其他用户所作的评论,类型:array,例子: [“Group2”, “”];
view
用户可以查看其他用户的评论,类型:array,例子: [“Group2”, “”]
[“”]值表示用户可以编辑/删除/查看不属于这些组的人所做的评论(例如,如果文档在第三方编辑器中审阅)。如果值为[],则用户无法编辑/删除/查看任何组的评论。如果编辑、删除和查看参数为“”或未指定,则用户可以查看/编辑/删除任何用户的评论。
copy boolean 定义是否可以将内容复制到剪贴板。如果参数设置为false,则粘贴内容将仅在当前文档编辑器中可用。默认值为true。 true
deleteCommentAuthorOnly boolean 定义用户是否只能删除他/她的批注。默认值为false。 true
download boolean 定义文档是可以下载还是只能在线查看或编辑。如果download设置为“false”,则“文件”菜单中将不存在“下载为…”菜单选项。默认值为true。 true
edit boolean 定义文档是可以编辑还是只能查看。如果edit设置为“true”,“文件”菜单将包含“编辑文档”菜单选项;请注意,如果edit设置为“false”,文档将在查看器中打开,如图,即使mode参数设置为edit,您也无法将其切换到编辑器。默认值为true。
在这里插入图片描述
true
editCommentAuthorOnly boolean 定义用户是否只能编辑他/她的批注。默认值为false。 true
fillForms boolean 定义是否可以填写表单。只有在mode参数设置为’edit’时,文档编辑器才可以填写表单。默认值与editreview参数的值一致。
如果edit设置为“true”或review设置为“true”,则不考虑fillForms,可以填写表单。如果edit设置为“false”,review设置为“false”,fillForms也设置为“true”,则用户只能在文档中填写表单。如果edit设置为“false”,review设置为“false”,fillForm设置为“true”,则不考虑comment值,注释不可用。仅表单填充模式当前仅适用于文档编辑器。
true
modifyContentControl boolean 定义是否可以更改内容控件设置。如果mode参数设置为’edit’,则内容控件修改仅可用于文档编辑器。默认值为true。 true
modifyFilter boolean 定义过滤器是可以全局应用(true)影响所有其他用户,还是本地应用(false),即仅适用于当前用户。仅当mode参数设置为’edit’时,电子表格编辑器才可以修改过滤器。默认值为true。
如果文档是由具有完全访问权限的用户编辑的,则该用户应用的筛选器将对所有其他用户可见,无论其本地设置如何。
true
print boolean 定义是否可以打印文档。如果print设置为“false”,则“文件”菜单中将不存在“打印”菜单选项。默认值为true。 true
protect boolean 定义工具栏上的保护选项卡和左侧菜单中的保护按钮是显示(true)还是隐藏(false)。默认值为true。 true
rename boolean 在使用onRequestRename 事件时是否允许显示重命名按钮。默认值为false。自6.0版起已弃用,请onRequestRename字段。 true
review boolean 定义是否可以审阅文档。如果review设置为true,文档状态栏将包含“审阅”菜单选项;如果mode参数设置为’edit’,文档审阅将仅对文档编辑器可用。默认值与edit参数的值一致。 true
reviewGroups Array 定义用户可以接受/拒绝其更改的组。[“”]值意味着用户可以查看不属于这些组的人所做的更改(例如,如果在第三方编辑器中查看文档)。如果值为[],则用户无法查看任何组所做的更改。如果值为“”或未指定,则用户可以查看任何用户所做的更改
userInfoGroups Array 定义其信息显示在编辑器中的用户组:
用户名显示在编辑器标题中的编辑用户列表中。
当键入文本时,显示带有其名称的用户光标和工具提示。
在严格协同编辑模式下锁定对象时,将显示用户名。
[“Group1”,“”]表示显示有关Group1中的用户和不属于任何组的用户的信息。[]表示根本不显示用户信息。未定义或“”值表示显示所有用户的信息。
(2)editorConfig对象
参数名称 类型 描述 例子
actionLink object 使用data.Action Link参数中的onMakeActionLink事件或onRequestSendNotify事件指定从文档编辑服务接收的数据,该参数包含有关将滚动到的文档中的操作的信息。
createUrl string 定义将在其中创建文档的绝对URL,并在创建后可用。如果未指定,将没有创建按钮。您可以使用on Request Create New事件来代替此字段 “https://example.com/url-to-create-document/”
mode string 定义编辑器打开模式。可以查看以打开文档进行查看,也可以编辑以在编辑模式下打开文档,以便对文档数据进行更改。默认值为“edit” “edit”
templates Array 定义“新建…”中是否存在模板。。。菜单选项,其中可以设置以下文档参数:
image -模板图像的绝对URL,类型:string,例子:“https://example.com/exampletemplate1.png”;
title -将显示在“新建…”中的模板标题。。。菜单选项,类型:string,例子 :“exampletemplate1.docx”;
url -文档的绝对URL,该文档将在其中创建,类型:string,例子:“https://example.com/url-to-create-template1”.
callbackUrl string 指定文档存储服务的绝对URL(必须由在自己的服务器上使用ONLYOFFICE document Server的软件集成商实现)。 “https://example.com/url-to-callback.ashx”
lang string 定义编辑器界面语言(如果存在英语以外的其他语言)。使用两个字母(de、ru、it等)语言代码设置。默认值为“en”。 “en”
recent Array 定义“最近打开的文档”中文档的存在或不存在。。。菜单选项,其中可以设置以下文档参数:
folder-存储文档的文件夹(在文档存储在根文件夹中的情况下可以是空的),类型:string,例子:“Example Files”;
title -将显示在“最近打开的…”中的文档标题。。。菜单选项,类型:string,例子:“exampledocument1.docx”;
url -存储它的文档的绝对URL,类型:string,例子:“https://example.com/exampledocument1.docx”
user object 定义当前查看或编辑文档的用户:
firstname -用户的名字。自4.2版起已弃用,请改用name,string
group- 用户所属的组,string
id -用户的标识。长度限制为128个符号。存储此信息并将其用于区分共同作者,在保存和突出显示历史记录(在更改列表中)时指明上次更改的作者,并根据用户数量统计有权访问许可证的用户。我们建议使用一些独特的匿名哈希。请勿在此字段中使用敏感数据,如姓名或电子邮件。string
lastname-用户的姓氏,string
name -用户的全名。长度限制为128个符号。从版本4.2开始使用,string
{
group:‘Group1’,
id: ‘5454356’,
lastname:‘Smith’,
name: ‘John Smith’
}
coEditing object 定义联合编辑模式(快速或严格)以及更改它的可能性。该对象具有以下参数:
mode-联合编辑模式(快速或严格)。默认值是‘fast’
change -定义是否可以在编辑器界面中更改协同编辑模式。默认值为真,
此参数用于应用协同编辑和查看模式。
{mode: ‘strict’,change: false}
location string 定义默认测量单位。指定我们或ca来设置英寸。默认值为“”。
请注意,设置us或ca值时,默认测量单位为英寸
‘’
region string 定义货币、日期和时间的默认显示格式(仅在电子表格编辑器中)。使用四个字母(en-US、fr-fr等)语言代码设置。对于默认值,采用lang参数,或者,如果没有与lang值对应的区域设置可用,则使用en-US。 “en-US”
Customization对象
参数名称 类型 描述 例子
anonymous object 添加对匿名名称的请求:
request - 定义是否发送请求。 默认值为 true, 类型:boolean, 示例:true;
label - 添加到用户名的后缀。 默认值为 Guest, 类型:string, 示例:“Guest”;
在这里插入图片描述
features object 如果可能,定义用户可以禁用或自定义的参数:
spellcheck - 定义在加载编辑器时拼写检查器是自动打开还是关闭。 如果此参数为布尔值,则将其设置为初始拼写检查值,并且不会隐藏拼写检查设置。 默认值为 true, 类型:object 或 boolean, 例如:true;
spellcheck.mode - 定义在加载编辑器时拼写检查器是自动打开还是关闭。 此参数仅适用于文档编辑器和演示文稿编辑器, 类型:boolean, 示例:true;
object 更改编辑器标题左上角的图像文件。 推荐的图像高度为 20 像素。 该对象具有以下参数:
image - 用于在通用工作模式(即所有编辑器的查看和编辑模式)或嵌入模式(请参阅配置部分以了解如何定义embedded文档类型)中显示的图像文件的路径。 图片必须具有以下尺寸:172x40,172x40, 类型:string, 示例:“https://example.com/logo.png”;
imageDark - 用于深色主题的图像文件的路径。 图片必须具有以下尺寸:172x40,172x40, 类型:string, 示例:“https://example.com/dark-logo.png”;
imageEmbedded - 用于以嵌入模式显示的图像文件的路径(请参阅配置部分以了解如何定义 embedded文档类型)。 图片必须具有以下尺寸:248x40。 自 7.0 版起已弃用,请改用 image字段, 类型:string, 示例:“https://example.com/logo_em.png”;
url - 当有人单击徽标图像时将使用的绝对 URL(可用于访问您的网站等)。 保留为空字符串或 null 以使徽标不可点击, 类型:string, 示例**:**“https://example.com”。
toolbarHideFileName boolean 定义文档标题在顶部工具栏上是可见的 (false) 还是隐藏的 (true)。 默认值为 false
请注意,当 compactHeadertoolbarNoTabs参数设置为 true时使用此设置。
false
autosave boolean 定义 自动保存 菜单选项是启用还是禁用。 如果设置为 false,则只能选择 Strict 共同编辑模式,因为 Fast 在没有自动保存的情况下不起作用。 默认值为 true
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.autosave 参数发送的任何值。
在这里插入图片描述
false
feedback boolean或者object 定义 反馈和支持 菜单按钮的设置。 可以是布尔值(仅显示或隐藏 反馈和支持 菜单按钮)或对象。 在对象类型的情况下,以下参数可用:
url - 单击 反馈和支持 菜单按钮时将打开的网站绝对URL, 类型:string, 示例:“https://example.com”;
visible - 显示或隐藏 反馈和支持 菜单按钮, 类型:boolean, 示例:true。
默认值为 false
macros boolean 定义当编辑器打开时是否自动运行文档宏。 默认值为 truefalse值对用户隐藏宏设置。 true
macrosMode string 定义启用自动开始时的宏运行模式。 可以取以下值:
disable - 不自动运行所有宏;
enable - 自动运行所有宏;
warn - 对运行宏发出警告并请求运行它们的权限。
默认值为 warn
warn
toolbarNoTabs boolean 定义顶部工具栏选项卡是清晰显示 (false) 还是仅突出显示以查看选择了哪个 (true)。 默认值为 false
在这里插入图片描述
true
chat boolean 定义聊天菜单按钮是显示还是隐藏。 请注意,如果您隐藏聊天按钮,相应的聊天功能也将被禁用。 默认值为 true。 自 7.1 版起已弃用,请改用 document.permissions.chat 参数。 false
forcesave boolean 在文档编辑服务中保存文档时(例如单击 保存** 按钮等),将文件强制保存请求添加到 calllback。 默认值为 false true
trackChanges boolean 无论 document.permissions.review 参数如何, 定义是(true)否(false)以审阅编辑模式打开文档(仅针对当前用户更改审阅模式)。 如果参数是 未定义,则使用 document.permissions.review 值(对于所有文档用户)。
自 7.0 版起已弃用。请改用 review.trackChanges 参数。
true
commentAuthorOnly boolean 定义用户是否只能编辑和删除他的评论。 默认值为 false。 自 6.3 版起已弃用,请改用 document.permissions.editCommentAuthorOnlydocument.permissions.deleteCommentAuthorOnly字段。 true
goback boolean 或 object 定义 打开文件位置 菜单按钮和右上角按钮的设置。 该对象具有以下参数:
Blank - 单击 打开文件位置按钮时,在新浏览器选项卡/窗口(如果值设置为 true)或当前选项卡(如果值设置为 false )中打开网站。 默认值为 true, 类型:boolean, 示例:true;
requestClose - 定义如果单击打开文件位置按钮,将调用 events.onRequestClose 事件而不是打开浏览器选项卡或窗口。 默认值为 false, 类型:boolean, 示例:false;
text - 打开文件位置 菜单按钮和右上角按钮显示的文本(也就是说,不是 转到文档), 类型:string, 例如:“打开文件位置”;
url - 单击 打开文件位置 菜单按钮时将打开的网站绝对 URL, 类型:string, 例如:“https://example.com”。
true
mentionshare boolean 定义在评论中提及后描述事件的提示。 如果为 true,则提示表示用户将收到通知并访问文档。 如果为 false,则提示表示用户将仅收到提及通知。 默认值为 true
请注意,如果设置了 onRequestSendNotify 事件 ,它将仅可用于评论。
true
uiTheme string 定义编辑器主题设置。 可以通过两种方式设置:
theme id - 用户通过其 id 设置主题参数(theme-light, theme-classic-light, theme-dark, theme-contrast-dark),
default theme - 将设置默认的深色或浅色主题值(default-dark,default-light)。
默认的浅色主题是 theme-classic-light。
第一个选项具有更高的优先级。
除了可用的编辑器主题外,用户还可以为应用程序界面自定义自己的颜色主题。
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.uiTheme 参数发送的任何值。
theme-dark
help boolean 定义 帮助 菜单按钮是显示还是隐藏。 默认值为 true
在这里插入图片描述
true
plugins boolean 定义插件是否将启动并可用。 默认值为 true true
unit string 定义标尺和对话框中使用的测量单位。 可以取以下值:
cm - 厘米, pt - 点, inch - 英寸。
默认值为厘米 (cm)。
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.unit 参数发送的任何值。
cm
compactHeader boolean 定义附加操作按钮是显示在编辑器窗口标题的上部靠近徽标 (false) 还是显示在工具栏 (true) 中,使标题更紧凑。 默认值为 false
在这里插入图片描述
false
hideNotes boolean 定义注释面板在首次加载时是显示还是隐藏。 默认值为 false。此参数仅适用于演示文稿编辑器。
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.hideNotes 参数发送的任何值。
在这里插入图片描述
false
review object 包含有关审阅模式的信息。 该对象具有以下参数:
hideReviewDisplay - 定义 显示模式 按钮是在 协作 选项卡上显示还是隐藏。 默认值为 false, 类型:boolean, 示例:false;
hoverMode - 定义评论显示模式:通过悬停更改(true) 在工具提示中显示评论,或者通过单击更改(false)在气球中显示评论。 默认值为 false。 类型:boolean, 示例:false;
reviewDisplay - 定义打开文档进行查看时将使用的审阅编辑模式。 如果 mode 设置为 view,它将仅对文档编辑器可用。 可以取以下值:
- markup - 显示文档,并突出显示建议的更改;
- simple - 显示文档并突出显示建议的更改,但气球已关闭;
- final - 显示文档并应用了所有建议的更改;
- original - 显示原始文档,没有建议的更改。 默认值为 original, 类型:string, 示例:“original”;
showReviewChanges - 定义在加载编辑器时是否自动显示或隐藏审阅更改面板。 默认值为 false, 类型:boolean, 示例:false;
trackChanges - 无论 document.permissions.review 参数如何,定义是否以审阅编辑模式 (true) 打开文档 (false) (审阅模式仅针对当前用户更改)。 如果参数 未定义,则使用 document.permissions.review 值(对于所有文档用户), 类型:boolean, 示例:true。
showReviewChanges, reviewDisplay, trackChanges参数自 7.0 版起已弃用。 请改用 review 参数。
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.review.hoverMode 和 editorConfig.customization.review.reviewDisplay 参数发送的任何值。
zoom integer 定义以百分比测量的文档显示缩放值。 可以取大于 0的值。 对于文本文档和演示文稿,可以将此参数设置为 -1 (使文档适合页面选项)或 -2 (使文档页面宽度适合编辑器页面)。 默认值为 100 100
compactToolbar boolean 定义显示的顶部工具栏类型是完整的 (false) 还是紧凑的 (true)。 默认值为 false
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.compactToolbar 参数发送的任何值。
false
hideRightMenu boolean 定义第一次加载时是否显示或隐藏右侧菜单。 默认值为 false
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.hideRightMenu 参数发送的任何值。
false
reviewDisplay string 定义文档编辑器中的审阅编辑模式。 此参数可以采用以下值:
markup - 显示文档并突出显示建议的更改;
simple - 显示文档并突出显示建议的更改,但气球已关闭;
final - 显示文档并应用所有建议的更改;
original - 显示原始文档,没有建议的更改。
查看器的默认值是 original, 编辑器的默认值是 markup
自 7.0 版起已弃用。请改用 review.reviewDisplay 参数。
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.reviewDisplay 参数发送的任何值。
original
compatibleFeatures boolean 定义仅与 OOXML 格式兼容的功能的使用。 例如,不要对整个文档使用注释。 默认值为 false true
hideRulers boolean 定义编辑器标尺是显示还是隐藏。 此参数可用于文档和演示文稿编辑器。文档编辑器的默认值为 false,演示文稿的默认值为 true
在这里插入图片描述
true
showReviewchanges boolean 定义加载编辑器时是否自动显示或隐藏审阅更改面板。 默认值为 false
自 7.0 版起已弃用。请改用 review.showReviewChanges 参数。
false
customer object 包含将在编辑器 关于 部分中显示的信息,并对所有编辑器用户可见。 该对象具有以下参数:
address - 允许访问编辑或编辑作者的公司或个人的邮政地址, 类型:字符串, 示例**:“My City, 123a-45”;
info - 关于您希望其他人知道的公司或个人的一些附加信息, 类型:字符串, 示例:“Some additional information”;
logo - 图片 logo 的路径(这个文件没有特别推荐,但是如果是透明背景的 .png 格式会更好)。 图片必须具有以下尺寸:432x70, 类型:string, 示例:“https://example.com/logo-big.png”。
logoDark
- 深色主题图像徽标的路径(此文件没有特别建议,但如果是透明背景的 .png 格式会更好)。 图片必须具有以下尺寸:432x70, 类型:string, 示例:“https://example.com/dark-logo-big.png”。
mail - 允许访问编辑或编辑作者的公司或个人的电子邮件地址, 类型:string, 示例:“[email protected]”.
name - 授予编辑或编辑作者访问权限的公司或个人的名称, 类型:string, 示例
:**“John Smith and Co.”;
phone-允许访问编辑或编辑作者的公司或个人的电话, 类型:string, 示例:“123456789”;
www - 上述公司或个人的主页地址, 类型:string, 示例:“example.com”。
integrationMode string 定义将编辑器嵌入网页的模式。 embed 值禁止在加载编辑器框架时滚动到编辑器框架,因为焦点未被捕获。 embed
spellcheck boolean 定义在加载编辑器时拼写检查器是自动打开还是关闭。 拼写检查器仅适用于文档编辑器和演示文稿编辑器。 默认值为 true
自 7.1 版起已弃用。请改用 features.spellcheck 参数。
请注意,如果在编辑器界面中更改此设置,它将存储在浏览器本地存储中,并将覆盖作为 editorConfig.customization.spellcheck 参数发送的任何值。
true
Embedded对象
参数名称 类型 描述 例子
embedUrl string 定义文档的绝对 URL,作为嵌入网页的文档的源文件。 “https://example.com/embedded?doc=exampledocument1.docx”
fullscreenUrl string 定义将以全屏模式打开的文档的绝对 URL。 “https://example.com/embedded?doc=exampledocument1.docx#fullscreen”
saveUrl string 定义允许将文档保存到用户个人计算机上的绝对 URL。 “https://example.com/download?doc=exampledocument1.docx”
shareUrl string 定义允许其他用户共享此文档的绝对 URL。 “https://example.com/view?doc=exampledocument1.docx”
toolbarDocked string 定义嵌入式查看器工具栏的位置,可以是 topbottom “top”
Plugins对象
参数名称 类型 描述 例子
autostart string数组 定义插件的标识符数组(在 config.json中输入),它将在编辑器打开时自动启动,并且插件将依次运行。
pluginsData string数组 定义插件配置文件 (config.json) 的绝对 URL 数组。
url string 定义存储插件的目录的绝对 URL。 自 4.3 版起已弃用,请在 pluginsData 字段中使用绝对 URL。
(3)events对象
参数名称 参数 描述
onAppReady 当应用程序加载到浏览器时调用的函数。
onCollaborativeChanges 当文档被其他用户在 严格 的共同编辑模式下共同编辑时调用的函数。
onDocumentReady 当文档加载到文档编辑器时调用的函数。
onDocumentStateChange 修改文档时调用的函数。 使用以下参数调用它:{“data”: true} --适用于当前用户正在编辑文档时。使用以下参数调用它:{“data”: false} --适用于当前用户的更改发送到 文档编辑服务时。
onDownloadAs event 调用 downloadAs 方法时使用已编辑文件的绝对 URL 调用的函数。 要下载的文档的绝对 URL 及其类型在 data 参数中发送。
onError event 发生错误或其他特定事件时调用的函数。 错误消息在 data 参数中发送。
onInfo event 应用程序打开文件时调用的函数。 模式在 data.mode 参数中发送。 可以 查看编辑
onMetaChange event 通过 meta 命令更改文档的元信息时调用的函数。 文档的名称在 data.title 参数中发送。 收藏 图标高亮状态在 data.favorite 参数中发送。 当用户点击 收藏 图标时, 调用setFavorite方法更新 收藏 图标高亮状态信息。 如果未声明该方法,则收藏 图标不会更改。
onMakeActionLink event 当用户试图获取打开包含书签的文档的链接时调用的函数,滚动到书签位置。 要设置书签链接,您必须调用 setActionLink 方法。 书签数据在 data 参数中接收,然后必须在配置中用作 editorConfig.actionLink 参数的值。 如果未声明该方法,则不会显示 获取链接 按钮。
onOutdatedVersion 显示 错误 后调用的函数,当使用旧的 document.key 值打开文档进行编辑时,该值用于编辑以前的文档版本并成功保存。 调用此事件时,必须使用新的 document.key重新初始化编辑器。
onPluginsReady 当所有插件都加载并可以使用时调用的函数。
onReady 当应用程序加载到浏览器中时调用的函数。 自 5.0 版起已弃用,请改用 onAppReady
onRequestClose 当编辑器的工作必须结束并且编辑器必须关闭时调用的函数。
onRequestCompareFile 当用户通过单击 存储中的文档 按钮尝试选择要比较的文档时调用的函数。 要选择一个文档进行比较,您必须调用 setRevisedFile 方法。 如果未声明该方法,则不会显示 存储中的文档 按钮。
- 仅适用于 ONLYOFFICE 企业版和 ONLYOFFICE 开发者版
onRequestCreateNew 当用户试图通过单击 新建 按钮来创建文档时调用的函数。 此方法用于代替 createUrl 字段。 如果未声明该方法且未指定 createUrl,则不会显示 新建 按钮。
onRequestEditRights 当用户试图通过单击 编辑文档 按钮将文档从查看模式切换到编辑模式时调用的函数。 调用该函数时,编辑器必须再次初始化,处于编辑模式。 如果未声明该方法,则不会显示 编辑 按钮。
editorConfig 模式 参数设置为view 并且 编辑 文档的 权限 (document permissions)设置为 true 时, onRequestEditRights 参数是强制性的,以便用户可以切换到编辑模式。
onRequestHistory 当用户试图通过单击 版本历史 按钮来显示文档版本历史时调用的函数。 要显示文档版本历史记录,您必须调用 refreshHistory 方法。 如果未声明该方法和 onRequestHistoryData 方法,则不会显示 版本历史 按钮。
onRequestHistoryClose 当用户试图通过单击 关闭历史记录 按钮查看文档版本历史记录返回文档时调用的函数。 调用该函数时,编辑器必须再次初始化,处于编辑模式。 如果未声明该方法,则不会显示 关闭历史记录 按钮。
onRequestHistoryData event 当用户试图点击文档版本历史中的特定文档版本时调用的函数。 要显示与特定文档版本相对应的更改,您必须调用 setHistoryData 方法。 文档版本号在 data 参数中发送。 如果未声明该方法和 onRequestHistory 方法,则不会显示 版本历史 按钮。
onRequestInsertImage event 当用户尝试通过单击 存储中的图像 按钮插入图像时调用的函数。 图像插入的类型在参数 data.c中指定。 要将图像插入文件,您必须使用指定的命令调用 insertImage 方法。 如果未声明该方法,则不会显示 Image from Storage 按钮。
onRequestMailMergeRecipients 当用户试图通过单击 邮件合并 按钮来选择收件人数据时调用的函数。 要选择收件人数据,您必须调用 setMailMergeRecipients 方法。 如果未声明该方法, 邮件合并 按钮将变淡且不可点击。
onRequestReferenceData 当用户通过单击数据选项卡外部链接对话框中的更新值 按钮而尝试刷新从外部文件插入的数据时,函数被调用。 要通过事件参数指定的文件链接刷新数据,您必须调用 setReferenceData 方法。 具有唯一文件数据和文件路径或名称的对象在 data 参数中发送。 如果未声明该事件,则不会显示粘贴链接更新值 按钮。
要将数据发送给setReferenceData方法,建议先通过referenceData参数搜索文件。 如果没有这样的字段或找不到文件,则使用 path 参数。
onRequestRename event 当用户试图通过单击 重命名… 按钮重命名文件时调用的函数。
在 6.0 版之前, 重命名… 按钮仅在 document.permissions.rename 设置为 true时可用。
onRequestRestore event 当用户试图通过单击版本历史记录中的 恢复 按钮来恢复文件版本时调用的函数。 调用该函数时,必须再次调用 refreshHistory 方法来初始化版本历史。 如果从历史记录中调用文档版本,则在 data.version 参数中发送文档版本号。 此外,如果从 history object中调用文档更改,则会在 data.url 参数中发送文档链接。 使用此链接指定的文档类型在 data.fileType 中发送范围。 如果未声明该方法,则不会显示 恢复 按钮。
onRequestSaveAs event 当用户试图通过单击 另存为… 按钮来保存文件时调用的函数。 文档的标题、其类型和要下载的文档的绝对 URL 在 data 参数中发送。 如果未声明该方法,将不会显示 另存为… 按钮。
onRequestSendNotify event 当评论中提到用户时调用的函数。 要提及的用户列表应通过 setUsers 方法完成。 消息和电子邮件列表在 data 参数中发送。 注释数据在 data.actionLink 参数中接收,然后必须在配置中用作 editorConfig.actionLink 参数的值。
在 5.4 版本中,只有在设置了 onRequestUsers 事件时才能使用 onRequestSendNotify 事件。 从 5.5 版开始, onRequestSendNotifyonRequestUsers 之间没有这种依赖关系两者都可以独立设置。
onRequestSharingSettings 当用户试图通过单击 更改访问权限 按钮来管理文档访问权限时调用的函数。 当访问权限发生变化时,您必须调用 setSharingSettings 方法来更新有关允许与其他用户共享文档的设置的 信息。 如果未声明该方法,则不会显示 更改访问权限 按钮。
onRequestUsers 当评论者可以选择其他用户在评论中提及时调用的函数。 要设置用户列表,您必须调用 setUsers 方法。
onWarning event 发生警告时调用的函数。 警告消息在 data 参数中发送。

3、参数示例

config = {
    
    
    "document": {
    
    
        "fileType": "docx",
        "info": {
    
    
            "favorite": true,
            "folder": "Example Files",
            "owner": "John Smith",
            "sharingSettings": [
                {
    
    
                    "permissions": "Full Access",
                    "user": "John Smith"
                },
                {
    
    
                    "isLink": true,
                    "permissions": "Read Only",
                    "user": "External link"
                },
                {
    
    
                    ...,
                }
            ],
            "uploaded": "2010-07-07 3:46 PM"
        },
        "key": "Khirz6zTPdfd7",
        "permissions": {
    
    
            "chat": true,
            "comment": true,
            "commentGroups": [
                "edit": ["Group2", ""],
                "remove": [""],
                "view": ""
            ],
            "copy": true,
            "deleteCommentAuthorOnly": false,
            "download": true,
            "edit": true,
            "editCommentAuthorOnly": false,
            "fillForms": true,
            "modifyContentControl": true,
            "modifyFilter": true,
            "print": true,
            "protect": true,
            "review": true,
            "reviewGroups": ["Group1", "Group2", ""],
            "userInfoGroups": ["Group1", ""]
        },
        "referenceData": {
    
    
            "fileKey": "BCFA2CED",
            "instanceId": "https://example.com"
        },
        "title": "Example Document Title.docx",
        "url": "https://example.com/url-to-example-document.docx"
    },
    "documentType": "word",
    "editorConfig": {
    
    
        "actionLink": ACTION_DATA,
        "callbackUrl": "https://example.com/url-to-callback.ashx",
        "coEditing": {
    
    
            "mode": "fast",
            "change": true
        },
        "createUrl": "https://example.com/url-to-create-document/",
        "customization": {
    
    
            "anonymous": {
    
    
                "request": true,
                "label": "Guest"
            },
            "autosave": true,
            "comments": true,
            "compactHeader": false,
            "compactToolbar": false,
            "compatibleFeatures": false,
            "customer": {
    
    
                "address": "My City, 123a-45",
                "info": "Some additional information",
                "logo": "https://example.com/logo-big.png",
                "logoDark": "https://example.com/dark-logo-big.png",
                "mail": "[email protected]",
                "name": "John Smith and Co.",
                "phone": "123456789",
                "www": "example.com"
            },
            "features": {
    
    
                "spellcheck": {
    
    
                    "mode": true,
                    "change": true
                }
            },
        "feedback": {
    
    
                "url": "https://example.com",
                "visible": true
            },
        "forcesave": false,
        "goback": {
    
    
                "blank": true,
                "requestClose":
                false, "text": "Open file location",
                "url": "https://example.com"
            },
            "help": true,
            "hideNotes": false,
            "hideRightMenu": false,
            "hideRulers": false,
            "integrationMode": "embed",
            "logo": {
    
    
                "image": "https://example.com/logo.png",
                "imageDark": "https://example.com/dark-logo.png",
                "url": "https://example.com"
            },
            "macros": true,
            "macrosMode": "warn",
            "mentionShare": true,
            "plugins": true,
            "review": {
    
    
                "hideReviewDisplay": false,
        "showReviewChanges": false,
                "reviewDisplay": "original",
                "trackChanges": true,
                "hoverMode": false
                },
        "toolbarHideFileName": false,
        "toolbarNoTabs": false,
        "uiTheme": "theme-dark",
        "unit": "cm",
        "zoom": 100
        },
        "embedded": {
    
    
            "embedUrl": "https://example.com/embedded?doc=exampledocument1.docx",
            "fullscreenUrl": "https://example.com/embedded?doc=exampledocument1.docx#fullscreen",
            "saveUrl": "https://example.com/download?doc=exampledocument1.docx",
            "shareUrl": "https://example.com/view?doc=exampledocument1.docx",
            "toolbarDocked": "top"
        },
        "lang": "en",
        "location": "us",
        "mode": "edit",
        "plugins": {
    
    
             "autostart": [
                 "asc.{0616AE85-5DBE-4B6B-A0A9-455C4F1503AD}",
                 "asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}",
        		...,
        	],
             "pluginsData": [
                 "https://example.com/plugin1/config.json",
                 "https://example.com/plugin2/config.json", 
                 ...,
             ]
        },
        "recent": [
            {
    
    
                "folder": "Example Files",
                "title": "exampledocument1.docx",
                "url": "https://example.com/exampledocument1.docx"
            },
            {
    
    
                "folder": "Example Files",
                "title": "exampledocument2.docx",
                "url": "https://example.com/exampledocument2.docx"
            },
            ...,
        ],
        "region": "en-US",
        "templates": [
            {
    
    
                "image": "https://example.com/exampletemplate1.png",
                "title": "exampletemplate1.docx",
                "url": "https://example.com/url-to-create-template1"
            },
            {
    
    
                "image": "https://example.com/exampletemplate2.png",
                "title": "exampletemplate2.docx",
                "url": "https://example.com/url-to-create-template2"
            },
            ...,
        ],
        "user": {
    
    
            "group": "Group1",
            "id": "78e1e841",
            "name": "John Smith"
        }
    },
    "events": {
    
    
        "onAppReady": onAppReady,
        "onCollaborativeChanges": onCollaborativeChanges,
        "onDocumentReady": onDocumentReady,
        "onDocumentStateChange": onDocumentStateChange,
        "onDownloadAs": onDownloadAs,
        "onError": onError,
        "onInfo": onInfo,
        "onMetaChange": onMetaChange,
        "onOutdatedVersion": onOutdatedVersion,
        "onPluginsReady": onPluginsReady,
        "onRequestClose": onRequestClose,
        "onRequestCompareFile": onRequestCompareFile,
        "onRequestCreateNew": onRequestCreateNew,
        "onRequestEditRights": onRequestEditRights,
        "onRequestHistory": onRequestHistory,
        "onRequestHistoryClose": onRequestHistoryClose,
        "onRequestHistoryData": onRequestHistoryData,
        "onRequestInsertImage": onRequestInsertImage,
        "onRequestMailMergeRecipients": onRequestMailMergeRecipients,
        "onRequestReferenceData": onRequestReferenceData,
        "onRequestRename": onRequestRename,
        "onRequestRestore": onRequestRestore,
        "onRequestSaveAs": onRequestSaveAs,
        "onRequestSendNotify": onRequestSendNotify,
        "onRequestSharingSettings": onRequestSaveAs,
        "onRequestUsers": onRequestUsers,
        "onWarning": onWarning
    },
    "height": "100%",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M",
    "type": "desktop",
    "width": "100%"
};

4、事件示例

onAppReady

var onAppReady = function () {
    
    
    console.log("ONLYOFFICE Document Editor is ready");
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onAppReady": onAppReady,
        ...
    },
    ...
});

onCollaborativeChanges

var onCollaborativeChanges = function () {
    
    
    console.log("The document changed by collaborative user");
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onCollaborativeChanges": onCollaborativeChanges,
        ...
    },
    ...
});

onDocumentReady

var onDocumentReady = function () {
    
    
    console.log("Document is loaded");
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onDocumentReady": onDocumentReady,
        ...
    },
    ...
});

onDocumentStateChange

var onDocumentStateChange = function (event) {
    
    
    if (event.data) {
    
    
        console.log("The document changed");
    } else {
    
    
        console.log("Changes are collected on document editing service");
    }
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onDocumentStateChange": onDocumentStateChange,
        ...
    },
    ...
});

onDownloadAs

var onDownloadAs = function (event) {
    
    
    var fileType = event.data.fileType;
    var url = event.data.url;
    console.log("ONLYOFFICE Document Editor create file: " + url);
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onDownloadAs": onDownloadAs,
        ...
    },
    ...
});

onError

var onError = function (event) {
    
    
    console.log("ONLYOFFICE Document Editor reports an error: code " + event.data.errorCode + ", description " + event.data.errorDescription);
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onError": onError,
        ...
    },
    ...
});

onInfo

var onInfo = function (event) {
    
    
    console.log("ONLYOFFICE Document Editor is opened in mode " + event.data.mode);
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onInfo": onInfo,
        ...
    },
    ...
});

onMetaChange

var onMetaChange = function (event) {
    
    
    var title = event.data.title;
    var favorite = event.data.favorite;
    ...
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onMetaChange": onMetaChange,
        ...
    },
    ...
});

onMakeActionLink

var onMakeActionLink = function (event){
    
    
    var ACTION_DATA = event.data;
    ...
    var link = GENERATE_LINK(ACTION_DATA);
    docEditor.setActionLink(link);
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onMakeActionLink": onMakeActionLink,
        ...
    },
    ...
});

onOutdatedVersion

var onOutdatedVersion = function () {
    
    
    location.reload(true);
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onOutdatedVersion": onOutdatedVersion,
        ...
    },
    ...
});

onPluginsReady

var onPluginsReady = function () {
    
    
    ...
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onPluginsReady": onPluginsReady,
        ...
    },
    ...
});

onRequestClose

var onRequestClose = function () {
    
    
    if (window.opener) {
    
    
        window.close();
        return;
    }
    docEditor.destroyEditor();
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestClose": onRequestClose,
        ...
    },
    ...
});

onRequestCompareFile

var onRequestCompareFile = function () {
    
    
    docEditor.setRevisedFile({
    
    
        "fileType": "docx",
        "url": "https://example.com/url-to-example-document.docx"
    });
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestCompareFile": onRequestCompareFile,
        ...
    },
    ...
});

onRequestCreateNew

var onRequestCreateNew = function () {
    
    
    ...
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestCreateNew": onRequestCreateNew,
        ...
    },
    ...
});

onRequestEditRights

var onRequestEditRights = function () {
    
    
    console.log("ONLYOFFICE Document Editor requests editing rights");
    document.location.reload();
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestEditRights": onRequestEditRights,
        ...
    },
    ...
});

onRequestHistory

var onRequestHistory = function () {
    
    
    docEditor.refreshHistory({
    
    
        "currentVersion": 2,
        "history": [
            {
    
    
                "changes": changes,
                "created": "2010-07-06 10:13 AM",
                "key": "af86C7e71Ca8",
                "serverVersion": serverVersion,
                "user": {
    
    
                    "id": "F89d8069ba2b",
                    "name": "Kate Cage"
                },
                "version": 1
            },
            {
    
    
                "changes": changes,
                "created": "2010-07-07 3:46 PM",
                "key": "Khirz6zTPdfd7",
                "user": {
    
    
                    "id": "78e1e841",
                    "name": "John Smith"
                },
                "version": 2
            },
            ...
        ]
    });
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestHistory": onRequestHistory,
        ...
    },
    ...
});
//其中 **changes** 是保存文档后返回的 [历史对象](https://api.onlyoffice.com/zh/editors/callback#history) 的 *更改*。

//其中 **serverVersion** 是保存文档后返回的 [历史对象](https://api.onlyoffice.com/zh/editors/callback#history) 中的 *serverVersion* 。

onRequestHistoryClose

var onRequestHistoryClose = function () {
    
    
    document.location.reload();
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestHistoryClose": onRequestHistoryClose,
        ...
    },
    ...
});

onRequestHistoryData

var onRequestHistoryData = function (event) {
    
    
    var version = event.data;
    docEditor.setHistoryData({
    
    
        "changesUrl": "https://example.com/url-to-changes.zip",
        "fileType": "docx",
        "key": "Khirz6zTPdfd7",
        "previous": {
    
    
            "fileType": "docx",
            "key": "af86C7e71Ca8",
            "url": "https://example.com/url-to-the-previous-version-of-the-document.docx"
        },
        "url": "https://example.com/url-to-example-document.docx",
        "version": version
    })
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestHistoryData": onRequestHistoryData,
        ...
    },
    ...
});
//其中 **changesUrl** 是保存文档后返回的json对象中的 *changesUrl*。

onRequestInsertImage

var onRequestInsertImage = function (event) {
    
    
    docEditor.insertImage({
    
    
        "c": event.data.c,
        "images": [
            {
    
    
        "fileType": "png",
                "url": "https://example.com/url-to-example-image1.png"
            },
            {
    
    
                "fileType": "png",
                "url": "https://example.com/url-to-example-image2.png"
            },
            ...
        ]
    });
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestInsertImage": onRequestInsertImage,
        ...
    },
    ...
});

onRequestMailMergeRecipients

var onRequestMailMergeRecipients = function () {
    
    
    docEditor.setMailMergeRecipients({
    
    
        "fileType": "xlsx",
        "url": "https://example.com/url-to-example-recipients.xlsx"
    });
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestMailMergeRecipients": onRequestMailMergeRecipients,
        ...
    },
    ...
});

onRequestReferenceData

var onRequestReferenceData = function () {
    
    
    var referenceData =  event.data.referenceData;
    var path = event.data.path;
    ...

    docEditor.setReferenceData({
    
    
        "fileType": "xlsx",
        "path": "sample.xlsx",
        "referenceData": {
    
    
            "fileKey": "BCFA2CED",
            "instanceId": "https://example.com"
        },
        "url": "https://example.com/url-to-example-document.xlsx"
    });
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestReferenceData": onRequestReferenceData,
        ...
    },
    ...
});

onRequestRename

var onRequestRename = function (event) {
    
    
    var title = event.data;
    ...
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestRename": onRequestRename,
        ...
    },
    ...
});

onRequestRestore

var onRequestRestore = function (event) {
    
    
    var fileType = event.data.fileType;
    var url = event.data.url;
    var version = event.data.version;
    ...
    docEditor.refreshHistory({
    
    
        "currentVersion": 2,
        "history": [
            {
    
    
                "changes": changes,
                "created": "2010-07-06 10:13 AM",
                "key": "af86C7e71Ca8",
                "serverVersion": serverVersion,
                "user": {
    
    
                    "id": "F89d8069ba2b",
                    "name": "Kate Cage"
                },
                "version": 1
            },
            {
    
    
                "changes": changes,
                "created": "2010-07-07 3:46 PM",
                "key": "Khirz6zTPdfd7",
                "user": {
    
    
                    "id": "78e1e841",
                    "name": "John Smith"
                },
                "version": 2
            },
            ...
        ]
    });
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestHistoryData": onRequestHistoryData,
        ...
    },
    ...
});
//其中 **changes** 是保存文档后返回的 [历史对象] 的 *更改*。

//其中 **serverVersion** 是保存文档后返回的 [历史对象] 中的 *serverVersion*。

onRequestSaveAs

var onRequestSaveAs = function (event) {
    
    
    var fileType = event.data.fileType;
    var title = event.data.title;
    var url = event.data.url;
    ...
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestSaveAs": onRequestSaveAs,
        ...
    },
    ...
});

onRequestSendNotify

var onRequestSendNotify = function (event) {
    
    
    var ACTION_DATA = event.data.actionLink;
    var comment = event.data.message;
    var emails = event.data.emails;
    ...
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestSendNotify": onRequestSendNotify,
        ...
    },
    ...
});

onRequestSharingSettings

var onRequestSharingSettings = function () {
    
    
    docEditor.setSharingSettings({
    
    
        "sharingSettings": [
            {
    
    
                "permissions": "Full Access",
                "user": "John Smith"
            },
            {
    
    
                "isLink": true,
                "permissions": "Read Only",
                "user": "External link"
            }
        ]
    });
    ...
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestSharingSettings": onRequestSharingSettings,
        ...
    },
    ...
});

onRequestUsers

var onRequestUsers = function () {
    
    
    docEditor.setUsers({
    
    
        "users": [
            {
    
    
                "email": "[email protected]",
                "name": "John Smith"
            },
            {
    
    
                "email": "[email protected]",
                "name": "Kate Cage"
            },
            ...
        ]
    });
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onRequestUsers": onRequestUsers,
        ...
    },
    ...
});

onWarning

var onWarning = function (event) {
    
    
    console.log("ONLYOFFICE Document Editor reports a warning: code " + event.data.warningCode + ", description " + event.data.warningDescription);
};

var docEditor = new DocsAPI.DocEditor("placeholder", {
    
    
    "events": {
    
    
        "onWarning": onWarning,
        ...
    },
    ...
});

Guess you like

Origin blog.csdn.net/qq_45099813/article/details/129615541