@seafile/sdoc-editor 0.3.26 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/basic-sdk/editor/sdoc-editor.js +13 -2
- package/dist/components/doc-operations/more-operations.js +21 -12
- package/dist/constants/index.js +3 -0
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/en/sdoc-editor.json +2 -1
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +3 -2
- package/public/locales/zh_CN/sdoc-editor.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React, { useEffect, useState, useImperativeHandle, forwardRef, useMemo } from 'react';
|
|
2
|
+
import React, { useEffect, useState, useImperativeHandle, forwardRef, useMemo, useCallback } from 'react';
|
|
3
3
|
import { Editor } from '@seafile/slate';
|
|
4
4
|
import deepCopy from 'deep-copy';
|
|
5
5
|
import context from '../../context';
|
|
@@ -17,6 +17,8 @@ import { HeaderToolbar } from '../extension';
|
|
|
17
17
|
import ReadOnlyArticle from '../views/readonly-article';
|
|
18
18
|
import { isMobile } from '../../utils';
|
|
19
19
|
import { CollaboratorsProvider } from '../../hooks';
|
|
20
|
+
import { EventBus } from '../../basic-sdk';
|
|
21
|
+
import { EXTERNAL_EVENT } from '../../constants';
|
|
20
22
|
const SdocEditor = forwardRef((_ref, ref) => {
|
|
21
23
|
let {
|
|
22
24
|
editor,
|
|
@@ -42,7 +44,7 @@ const SdocEditor = forwardRef((_ref, ref) => {
|
|
|
42
44
|
const [slateValue, setSlateValue] = useState(document.children);
|
|
43
45
|
useEffect(() => {
|
|
44
46
|
validEditor.readonly = false;
|
|
45
|
-
}, []);
|
|
47
|
+
}, [validEditor.readonly]);
|
|
46
48
|
|
|
47
49
|
// useMount: init socket connection
|
|
48
50
|
useEffect(() => {
|
|
@@ -76,6 +78,15 @@ const SdocEditor = forwardRef((_ref, ref) => {
|
|
|
76
78
|
};
|
|
77
79
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
80
|
}, []);
|
|
81
|
+
const onRefreshDocument = useCallback(() => {
|
|
82
|
+
window.location.reload();
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
// useMount: refresh document
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const eventBus = EventBus.getInstance();
|
|
88
|
+
eventBus.subscribe(EXTERNAL_EVENT.REFRESH_DOCUMENT, onRefreshDocument);
|
|
89
|
+
}, [onRefreshDocument]);
|
|
79
90
|
|
|
80
91
|
// The parent component can call the method of this component through ref
|
|
81
92
|
useImperativeHandle(ref, () => ({
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { useCallback, useState } from 'react';
|
|
2
2
|
import { withTranslation } from 'react-i18next';
|
|
3
3
|
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
|
4
|
+
import { EventBus } from '../../basic-sdk';
|
|
5
|
+
import { EXTERNAL_EVENT } from '../../constants';
|
|
4
6
|
import context from '../../context';
|
|
5
7
|
const MoreOperations = _ref => {
|
|
6
8
|
let {
|
|
@@ -10,15 +12,17 @@ const MoreOperations = _ref => {
|
|
|
10
12
|
const toggleDropdown = useCallback(isDropdownOpen => {
|
|
11
13
|
setIsDropdownOpen(!isDropdownOpen);
|
|
12
14
|
}, []);
|
|
15
|
+
const onFreezeDocument = useCallback(() => {
|
|
16
|
+
const eventBus = EventBus.getInstance();
|
|
17
|
+
eventBus.dispatch(EXTERNAL_EVENT.FREEZE_DOCUMENT);
|
|
18
|
+
}, []);
|
|
19
|
+
const unFreeze = useCallback(() => {
|
|
20
|
+
const eventBus = EventBus.getInstance();
|
|
21
|
+
eventBus.dispatch(EXTERNAL_EVENT.UNFREEZE);
|
|
22
|
+
}, []);
|
|
13
23
|
const parentFolderURL = context.getSetting('parentFolderURL');
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
dropdownItems.push({
|
|
17
|
-
text: t('Open_parent_folder'),
|
|
18
|
-
URL: parentFolderURL
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
if (dropdownItems.length === 0) return null;
|
|
24
|
+
const isPro = context.getSetting('isPro');
|
|
25
|
+
const isFreezed = context.getSetting('isFreezed');
|
|
22
26
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
23
27
|
isOpen: isDropdownOpen,
|
|
24
28
|
toggle: () => toggleDropdown(isDropdownOpen)
|
|
@@ -30,11 +34,16 @@ const MoreOperations = _ref => {
|
|
|
30
34
|
})), /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
31
35
|
className: "sdoc-dropdown-menu",
|
|
32
36
|
right: true
|
|
33
|
-
},
|
|
37
|
+
}, parentFolderURL && /*#__PURE__*/React.createElement(DropdownItem, {
|
|
34
38
|
className: "sdoc-dropdown-menu-item",
|
|
35
39
|
tag: "a",
|
|
36
|
-
href:
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
href: parentFolderURL
|
|
41
|
+
}, t('Open_parent_folder')), isPro && isFreezed && /*#__PURE__*/React.createElement(DropdownItem, {
|
|
42
|
+
className: "sdoc-dropdown-menu-item",
|
|
43
|
+
onClick: unFreeze
|
|
44
|
+
}, t('Unfreeze')), isPro && !isFreezed && /*#__PURE__*/React.createElement(DropdownItem, {
|
|
45
|
+
className: "sdoc-dropdown-menu-item",
|
|
46
|
+
onClick: onFreezeDocument
|
|
47
|
+
}, t('Freeze_Document'))));
|
|
39
48
|
};
|
|
40
49
|
export default withTranslation('sdoc-editor')(MoreOperations);
|
package/dist/constants/index.js
CHANGED
|
@@ -5,6 +5,9 @@ export const EXTERNAL_EVENT = {
|
|
|
5
5
|
TOGGLE_STAR: 'toggle_star',
|
|
6
6
|
UNMARK_AS_DRAFT: 'unmark_as_draft',
|
|
7
7
|
SHARE_SDOC: 'share_sdoc',
|
|
8
|
+
FREEZE_DOCUMENT: 'freeze_document',
|
|
9
|
+
UNFREEZE: 'unfreeze',
|
|
10
|
+
REFRESH_DOCUMENT: 'refresh_document',
|
|
8
11
|
PUBLISH_DOCUMENT: 'publish_document',
|
|
9
12
|
PUBLISH_DOCUMENT_ERROR: 'publish_document_error',
|
|
10
13
|
DOCUMENT_REPLACED: 'document_replaced',
|
package/package.json
CHANGED
|
@@ -424,5 +424,6 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"
|
|
427
|
+
"Freeze_Document": "Freeze Document",
|
|
428
|
+
"Unfreeze": "Unfreeze"
|
|
428
429
|
}
|
|
@@ -424,5 +424,6 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"
|
|
427
|
+
"Freeze_Document": "Freeze Document",
|
|
428
|
+
"Unfreeze": "Unfreeze"
|
|
428
429
|
}
|
|
@@ -424,5 +424,6 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"
|
|
427
|
+
"Freeze_Document": "Freeze Document",
|
|
428
|
+
"Unfreeze": "Unfreeze"
|
|
428
429
|
}
|
|
@@ -424,5 +424,6 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"
|
|
427
|
+
"Freeze_Document": "Freeze Document",
|
|
428
|
+
"Unfreeze": "Unfreeze"
|
|
428
429
|
}
|
|
@@ -424,5 +424,6 @@
|
|
|
424
424
|
"Row_number": "Row number",
|
|
425
425
|
"Column_number": "Column number",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "The maximum row number is {number}",
|
|
427
|
-
"
|
|
427
|
+
"Freeze_Document": "Freeze Document",
|
|
428
|
+
"Unfreeze": "Unfreeze"
|
|
428
429
|
}
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"Edit": "Редактировать",
|
|
55
55
|
"Copy": "Копировать",
|
|
56
56
|
"Copied": "Скопировано",
|
|
57
|
-
"Cut": "
|
|
57
|
+
"Cut": "Вырезать",
|
|
58
58
|
"Internal_link": "Внутренняя ссылка",
|
|
59
59
|
"Copy_internal_link": "Внутренняя ссылка скопирована в буфер обмена",
|
|
60
60
|
"Internal_link_desc": "Внутренняя ссылка - это ссылка на файл или папку, к которым могут обращаться пользователи с правами на чтение файла или папки.",
|
|
@@ -424,5 +424,6 @@
|
|
|
424
424
|
"Row_number": "Номер строки",
|
|
425
425
|
"Column_number": "Номер столбца",
|
|
426
426
|
"The_maximum_row_number_is_{number}": "Максимальное количество строк - {number}",
|
|
427
|
-
"
|
|
427
|
+
"Freeze_Document": "Freeze Document",
|
|
428
|
+
"Unfreeze": "Unfreeze"
|
|
428
429
|
}
|