Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/feature/editor-8.3.0' in…
Browse files Browse the repository at this point in the history
…to feature/onUserActionRequired

# Conflicts:
#	CHANGELOG.md
#	site/pages/Docs/Docs API/More Information/Changelog/index.md
  • Loading branch information
LinneyS committed Dec 24, 2024
2 parents 32f8bcb + edfe4be commit 6f91021
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

- docs api: added the events.onUserActionRequired event
- docs api: added the refreshFile method
- docs api: added the events.onRequestRefreshFile event
- docs api: the document editing will be prohibited for all users editing the document with the specified key, if the users parameter is not specified for the drop command
- docs api: the editorConfig.customization.submitForm parameter can now be used as an object
- docs api: the editorConfig.customization.compactToolbar parameter is now available for the viewer
Expand Down
Binary file modified site/assets/images/editor/e-key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions site/pages/Docs/Docs API/Additional API/Signature/Browser/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,59 @@ Sample token:
}
```

### refreshFile

When calling the [refreshFile](../../../Usage%20API/Methods/index.md#refreshFile) method to update the file version, the token must be added to validate the parameters.

The `payload` for the JWT token in the JSON format must have the same structure as the [config](../../../Usage%20API/Advanced%20parameters/index.md).

``` json
{
"document": {
"key": "Khirz6zTPdfd7",
"permissions": {
"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,
"review": true,
"reviewGroups": ["Group1", "Group2", ""]
},
"url": "https://example.com/url-to-example-document.docx"
},
"editorConfig": {
"callbackUrl": "https://example.com/url-to-callback.ashx",
"mode": "edit",
"user": {
"group": "Group1",
"id": "78e1e841",
"name": "Smith"
}
}
}
```

Where **example.com** is the name of the server where **document manager** and **document storage service** are installed. See the [How it works](../../../Get%20Started/How%20It%20Works/index.md) section to find out more on ONLYOFFICE Docs service client-server interactions.

Sample token:

``` json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb2N1bWVudCI6eyJrZXkiOiJLaGlyejZ6VFBkZmQ3IiwicGVybWlzc2lvbnMiOnsiY29tbWVudCI6dHJ1ZSwiY29tbWVudEdyb3VwcyI6eyJlZGl0IjpbIkdyb3VwMiIsIiJdLCJyZW1vdmUiOlsiIl0sInZpZXciOiIifSwiY29weSI6dHJ1ZSwiZGVsZXRlQ29tbWVudEF1dGhvck9ubHkiOmZhbHNlLCJkb3dubG9hZCI6dHJ1ZSwiZWRpdCI6dHJ1ZSwiZWRpdENvbW1lbnRBdXRob3JPbmx5IjpmYWxzZSwiZmlsbEZvcm1zIjp0cnVlLCJtb2RpZnlDb250ZW50Q29udHJvbCI6dHJ1ZSwibW9kaWZ5RmlsdGVyIjp0cnVlLCJwcmludCI6dHJ1ZSwicmV2aWV3Ijp0cnVlLCJyZXZpZXdHcm91cHMiOlsiR3JvdXAxIiwiR3JvdXAyIiwiIl19LCJ1cmwiOiJodHRwczovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3gifSwiZWRpdG9yQ29uZmlnIjp7ImNhbGxiYWNrVXJsIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS91cmwtdG8tY2FsbGJhY2suYXNoeCIsIm1vZGUiOiJlZGl0IiwidXNlciI6eyJncm91cCI6Ikdyb3VwMSIsImlkIjoiNzhlMWU4NDEiLCJuYW1lIjoiU21pdGgifX19.irYst9vmsLoQtC-95A-6W8DnbqGXCbmcxJajfbPh6tQ"
}
```

### setHistoryData

When calling the [setHistoryData](../../../Usage%20API/Methods/index.md#sethistorydata) method to view the document [history](../../../Get%20Started/How%20It%20Works/Document%20history/index.md) version in ONLYOFFICE Docs, the token must be added to validate the parameters.
Expand Down
2 changes: 2 additions & 0 deletions site/pages/Docs/Docs API/More Information/Changelog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ The list of changes of ONLYOFFICE Docs API.
## Version 8.3

- Added the [events.onUserActionRequired](../../Usage%20API/Config/Events/index.md#onuseractionrequired) event.
- Added the [refreshFile](../../Usage%20API/Methods/index.md#refreshfile) method.
- Added the [events.onRequestRefreshFile](../../Usage%20API/Config/Events/index.md#onrequestrefreshfile) event.
- The document editing will be prohibited for all users editing the document with the specified *key*, if the *users* parameter is not specified for the [drop](../../Additional%20API/Command%20service/drop/index.md) command.
- The [editorConfig.customization.submitForm](../../Usage%20API/Config/Editor/Customization/index.md#submitform) parameter can now be used as an object.
- The [editorConfig.customization.compactToolbar](../../Usage%20API/Config/Editor/Customization/index.md#compacttoolbar) parameter is now available for the viewer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Check if the [Callback handler](../../Usage%20API/Callback%20handler/index.md#ne

![The file version has been changed](/assets/images/editor/e-key.png)

The editor is loaded with the "The file version has been changed. The page will be reloaded" message.
The editor displays the "Connection is lost. Trying to connect. Please check connection settings." message.

The **document editing service** cannot open the previously edited and saved file for editing.
The **document editing service** is trying to update the file version without reloading the editor after the connection is lost.

Do not forget that every time the document is edited and saved, the [document.key](../../Usage%20API/Config/Document/index.md#key) must be generated anew.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ const config = {
onRequestOpen,
onRequestReferenceData,
onRequestReferenceSource,
onRequestRefreshFile,
onRequestRename,
onRequestRestore,
onRequestSaveAs,
Expand Down
37 changes: 36 additions & 1 deletion site/pages/Docs/Docs API/Usage API/Config/Events/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The events section allows to change all the functions pertaining to the events.
- [onRequestOpen](#onrequestopen) - the user is trying to open an external link.
- [onRequestReferenceData](#onrequestreferencedata) - the user is trying to refresh data inserted from the external file by clicking the *Update values* button in the *External* links dialog box of the *Data* tab.
- [onRequestReferenceSource](#onrequestreferencesource) - the user is trying to change an external link by clicking the *Change source* button.
- [onRequestRefreshFile](#onrequestrefreshfile) - the file version is updated without reloading the editor.
- [onRequestRename](#onrequestrename) - the user is trying to rename the file by clicking the *Rename...* button.
- [onRequestRestore](#onrequestrestore) - the user is trying to restore the file version by clicking the *Restore* button in the version history.
- [onRequestSaveAs](#onrequestsaveas) - the user is trying to save file by clicking *Save Copy as...* button.
Expand Down Expand Up @@ -218,7 +219,7 @@ const docEditor = new DocsAPI.DocEditor("placeholder", {

## onOutdatedVersion

The function called after the [error](../../../More%20Information/Troubleshooting/index.md#key) is shown, when the document is opened for editing with the old [document.key](../Document/index.md#key) value, which was used to edit the previous document version and was successfully saved. When this event is called the editor must be reinitialized with a new *document.key*.
The function called after the [error](../../../More%20Information/Troubleshooting/index.md#key) is shown, when the document is opened for editing with the old [document.key](../Document/index.md#key) value, which was used to edit the previous document version and was successfully saved. When this event is called the editor must be reinitialized with a new *document.key*. Deprecated since version 8.3, please use [onRequestRefreshFile](#onrequestrefreshfile) instead.

Example:

Expand Down Expand Up @@ -591,6 +592,40 @@ const docEditor = new DocsAPI.DocEditor("placeholder", {
})
```

## onRequestRefreshFile

The function called instead of the [onOutdatedVersion](#onoutdatedversion) event in the following cases:

- when the editor is opened with [key](../Document/index.md#key) that was already used to successfully save a file;
- when the editor reconnects to the server after losing the connection and interrupting the editing session.

In these cases, the [refreshFile](../../Methods/index.md#refreshfile) method is called and the file version is updated without reloading the editor.

Example:

``` ts
function onRequestRefreshFile() {
refreshFile({
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",
},
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb2N1bWVudCI6eyJmaWxlVHlwZSI6ImRvY3giLCJrZXkiOiJLaGlyejZ6VFBkZmQ3IiwidGl0bGUiOiJFeGFtcGxlIERvY3VtZW50IFRpdGxlLmRvY3giLCJ1cmwiOiJodHRwczovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3gifSwiZG9jdW1lbnRUeXBlIjoid29yZCIsImVkaXRvckNvbmZpZyI6eyJjYWxsYmFja1VybCI6Imh0dHBzOi8vZXhhbXBsZS5jb20vdXJsLXRvLWNhbGxiYWNrLmFzaHgifX0.vbezS2aM8Xf8qFzIAsO-jrIsi7VLxjRYkIkwh5jLTJU",
})
}
const docEditor = new DocsAPI.DocEditor("placeholder", {
events: {
onRequestRefreshFile,
},
})
```

## onRequestRename

The function called when the user is trying to rename the file by clicking the *Rename...* button.
Expand Down
23 changes: 23 additions & 0 deletions site/pages/Docs/Docs API/Usage API/Methods/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const docEditor = new DocsAPI.DocEditor("placeholder", config)
- [destroyEditor](#destroyeditor) - destroy *docEditor* object.
- [downloadAs](#downloadas) - download the edited file.
- [insertImage](#insertimage) - insert an image into the file.
- [refreshFile](#refreshfile) - update the file version without reloading the editor.
- [refreshHistory](#refreshhistory) - show the document version history.
- [requestClose](#requestclose) - request to close the editor.
- [setActionLink](#setactionlink) - set the link to the document which contains a bookmark.
Expand Down Expand Up @@ -118,6 +119,28 @@ Where **example.com** is the name of the server where **document manager** and *
>
> Please note that this structure is deprecated and will not be supported by the next editors versions. Please use a new one.
## refreshFile
Updates the file version without reloading the editor. This method must be called after the [onRequestRefreshFile](../Config/Events/index.md#onrequestrefreshfile) event.
This method must take the editor initialization configuration for the current file version. The configuration must contain all the parameters used for signing a request to [open a file](../../Additional%20API/Signature/Browser/index.md#opening-file) for editing. The following parameters cannot be changed in the config: [documentType](../Config/index.md#documenttype), [type](../Config/index.md#type), [events](../Config/Events/index.md).
``` ts
refreshFile({
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",
},
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb2N1bWVudCI6eyJmaWxlVHlwZSI6ImRvY3giLCJrZXkiOiJLaGlyejZ6VFBkZmQ3IiwidGl0bGUiOiJFeGFtcGxlIERvY3VtZW50IFRpdGxlLmRvY3giLCJ1cmwiOiJodHRwczovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3gifSwiZG9jdW1lbnRUeXBlIjoid29yZCIsImVkaXRvckNvbmZpZyI6eyJjYWxsYmFja1VybCI6Imh0dHBzOi8vZXhhbXBsZS5jb20vdXJsLXRvLWNhbGxiYWNrLmFzaHgifX0.vbezS2aM8Xf8qFzIAsO-jrIsi7VLxjRYkIkwh5jLTJU",
})
```
## refreshHistory

Show the document version history. This method must be called after the [onRequestHistory](../Config/Events/index.md#onrequesthistory) events.
Expand Down

0 comments on commit 6f91021

Please sign in to comment.