Skip to content

Commit 8f6067b

Browse files
committed
Merge pull request 'Release/1.6.0' from develop into master
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/document-editor-react/pulls/2
2 parents 89dd0c8 + 737d4e6 commit 8f6067b

File tree

11 files changed

+6170
-6200
lines changed

11 files changed

+6170
-6200
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Change Log
22

3+
## 1.6.0
4+
- added shardkey property
5+
36
## 1.5.1
47
- IConfig->document is not required
58

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var onLoadComponentError = function (errorCode, errorDescription) {
5555
5656
export default function App() {
5757
return (
58-
<pre>
58+
<>
5959
<DocumentEditor
6060
id="docxEditor"
6161
documentServerUrl="http://documentserver/"
@@ -132,6 +132,7 @@ The application will be deployed on the web server (*http://localhost:3000* by d
132132
| ------------- | ------------- | ------------- | ------------- | ------------- |
133133
| `id` | string | null | yes | Component unique identifier. |
134134
| `documentServerUrl` | string | null | yes | Address of ONLYOFFICE Document Server. |
135+
| `shardkey` | string \| boolean | true | no | The string or boolean parameter required to request load balancing during collaborative editing: all users editing the same document are served by the same server. [Shard key](https://api.onlyoffice.com/docs/docs-api/get-started/how-it-works/#shard-key)|
135136
| `config` | object | null | yes | Generic configuration object for opening a file with token. [Config API](https://api.onlyoffice.com/editors/config/) |
136137
| `onLoadComponentError` | (errorCode: number, errorDescription: string) => void | null | no | The function called when an error occurs while loading a component |
137138
| `document_fileType` | string | null | no | The type of the file. |

package-lock.json

Lines changed: 6118 additions & 6166 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onlyoffice/document-editor-react",
3-
"version": "1.5.1",
3+
"version": "1.6.0",
44
"description": "React component for ONLYOFFICE Document Server",
55
"license": "Apache-2.0",
66
"bugs": {
@@ -25,37 +25,37 @@
2525
"lodash": "4.17.21"
2626
},
2727
"devDependencies": {
28-
"@babel/core": "^7.23.9",
29-
"@babel/preset-env": "^7.23.9",
30-
"@babel/preset-react": "^7.23.3",
31-
"@babel/preset-typescript": "^7.23.3",
32-
"@rollup/plugin-commonjs": "^25.0.7",
33-
"@rollup/plugin-node-resolve": "^15.2.3",
28+
"@babel/core": "^7.26.7",
29+
"@babel/preset-env": "^7.26.7",
30+
"@babel/preset-react": "^7.26.3",
31+
"@babel/preset-typescript": "^7.26.0",
32+
"@rollup/plugin-commonjs": "^25.0.8",
33+
"@rollup/plugin-node-resolve": "^16.0.0",
3434
"@rollup/plugin-terser": "^0.4.4",
3535
"@rollup/plugin-typescript": "^11.1.6",
36-
"@storybook/addon-essentials": "^7.6.11",
37-
"@storybook/addon-interactions": "^7.6.11",
38-
"@storybook/addon-links": "^7.6.11",
39-
"@storybook/addon-onboarding": "1.0.11",
40-
"@storybook/blocks": "^7.6.11",
41-
"@storybook/react": "^7.6.11",
42-
"@storybook/react-webpack5": "^7.6.11",
43-
"@storybook/test": "^7.6.11",
44-
"@testing-library/react": "^14.2.0",
45-
"@types/jest": "^29.5.11",
46-
"@types/react": "^18.2.48",
36+
"@storybook/addon-essentials": "^7.6.20",
37+
"@storybook/addon-interactions": "^7.6.20",
38+
"@storybook/addon-links": "^7.6.20",
39+
"@storybook/addon-onboarding": "^1.0.11",
40+
"@storybook/blocks": "^7.6.20",
41+
"@storybook/react": "^7.6.20",
42+
"@storybook/react-webpack5": "^7.6.20",
43+
"@storybook/test": "^7.6.20",
44+
"@testing-library/react": "^16.2.0",
45+
"@types/jest": "^29.5.14",
46+
"@types/react": "^18.3.18",
4747
"babel-jest": "^29.7.0",
48-
"babel-loader": "^9.1.3",
48+
"babel-loader": "^9.2.1",
4949
"jest-environment-jsdom": "^29.7.0",
50-
"react": "^18.2.0",
50+
"react": "^18.3.1",
5151
"react-dom": "^18.2.0",
5252
"rollup": "^4.9.6",
53-
"rollup-plugin-dts": "^6.1.0",
53+
"rollup-plugin-dts": "^6.1.1",
5454
"rollup-plugin-filesize": "^10.0.0",
5555
"rollup-plugin-peer-deps-external": "^2.2.4",
56-
"storybook": "^7.6.11",
56+
"storybook": "^7.6.20",
5757
"tslib": "^2.6.2",
58-
"ts-jest": "^29.1.2",
58+
"ts-jest": "^29.2.5",
5959
"typescript": "^5.3.3"
6060
},
6161
"peerDependencies": {

src/DocumentEditor.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (c) Copyright Ascensio System SIA 2024
2+
* (c) Copyright Ascensio System SIA 2025
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/DocumentEditor.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (c) Copyright Ascensio System SIA 2024
2+
* (c) Copyright Ascensio System SIA 2025
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/DocumentEditor.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (c) Copyright Ascensio System SIA 2024
2+
* (c) Copyright Ascensio System SIA 2025
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ type DocumentEditorProps = {
3030
id: string;
3131

3232
documentServerUrl: string;
33+
shardkey?: string | boolean;
3334

3435
config: IConfig;
3536

@@ -78,6 +79,7 @@ const DocumentEditor = (props: DocumentEditorProps) => {
7879
id,
7980

8081
documentServerUrl,
82+
shardkey = true,
8183

8284
config,
8385

@@ -141,8 +143,16 @@ const DocumentEditor = (props: DocumentEditorProps) => {
141143
let url = documentServerUrl;
142144
if (!url.endsWith("/")) url += "/";
143145

144-
const docApiUrl = `${url}web-apps/apps/api/documents/api.js`;
145-
loadScript(docApiUrl, "onlyoffice-api-script")
146+
let docsApiUrl = `${url}web-apps/apps/api/documents/api.js`;
147+
if (shardkey) {
148+
if (typeof shardkey === "boolean") {
149+
docsApiUrl += `?shardkey=${config.document?.key}`;
150+
} else {
151+
docsApiUrl += `?shardkey=${shardkey}`;
152+
}
153+
}
154+
155+
loadScript(docsApiUrl, "onlyoffice-api-script")
146156
.then(() => onLoad())
147157
.catch(() => onError(-2));
148158

@@ -228,10 +238,12 @@ const DocumentEditor = (props: DocumentEditorProps) => {
228238
document.fileType = document_fileType;
229239
}
230240

231-
if (document_fileType) {
241+
if (document_title) {
232242
document = document || {};
233243
document.document_title = document_title;
234244
}
245+
246+
return document;
235247
}
236248

237249
const getEditorConfig = () => {
@@ -241,6 +253,8 @@ const DocumentEditor = (props: DocumentEditorProps) => {
241253
editorConfig = editorConfig || {};
242254
editorConfig.lang = editorConfig_lang;
243255
}
256+
257+
return editorConfig;
244258
}
245259

246260
const onError = (errorCode: number) => {

src/config/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"documentServerUrl": "http://documentserver/",
3-
"demoStorage": "https://d2nlctn12v279m.cloudfront.net/assets/docs/samples/"
3+
"demoStorage": "https://static.onlyoffice.com/assets/docs/samples/"
44
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (c) Copyright Ascensio System SIA 2024
2+
* (c) Copyright Ascensio System SIA 2025
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/model/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (c) Copyright Ascensio System SIA 2024
2+
* (c) Copyright Ascensio System SIA 2025
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)