@seafile/sdoc-editor 0.1.165 → 0.1.166-beta
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/assets/css/simple-viewer.css +10 -0
- package/dist/basic-sdk/editor/{slate-editor.js → editable-article.js} +8 -13
- package/dist/basic-sdk/editor/index.js +14 -52
- package/dist/basic-sdk/editor/{common-editor.js → sdoc-editor.js} +14 -12
- package/dist/basic-sdk/extension/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +18 -0
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +3 -3
- package/dist/basic-sdk/extension/toolbar/index.js +2 -2
- package/dist/basic-sdk/layout/editor-container.js +9 -17
- package/dist/basic-sdk/layout/editor-content.js +7 -15
- package/dist/basic-sdk/socket/helpers.js +0 -2
- package/dist/basic-sdk/socket/socket-manager.js +1 -2
- package/dist/basic-sdk/socket/with-socket-io.js +10 -17
- package/dist/basic-sdk/views/index.js +4 -3
- package/dist/basic-sdk/views/readonly-article.js +24 -0
- package/dist/basic-sdk/views/revision-diff-viewer.js +44 -0
- package/dist/basic-sdk/views/sdoc-diff-viewer.js +17 -0
- package/dist/basic-sdk/views/sdoc-viewer.js +35 -0
- package/dist/constants/index.js +0 -5
- package/dist/pages/simple-editor.js +35 -41
- package/package.json +1 -1
- package/public/locales/cs/sdoc-editor.json +1 -1
- package/public/locales/de/sdoc-editor.json +1 -1
- package/public/locales/en/sdoc-editor.json +1 -1
- package/public/locales/es/sdoc-editor.json +1 -1
- package/public/locales/fr/sdoc-editor.json +1 -1
- package/public/locales/it/sdoc-editor.json +1 -1
- package/public/locales/ru/sdoc-editor.json +4 -4
- package/public/locales/zh_CN/sdoc-editor.json +1 -1
- package/dist/basic-sdk/views/diff-viewer.js +0 -56
- package/dist/basic-sdk/views/viewer.js +0 -51
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
height: 100%;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
.sdoc-editor-container .sdoc-editor-content.no-outline .sdoc-absolute-wrapper {
|
|
6
|
+
display: flex;
|
|
7
|
+
position: relative;
|
|
8
|
+
min-height: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.sdoc-editor-container .sdoc-editor-content.no-outline .sdoc-article-container {
|
|
12
|
+
margin-left: 0 !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
.sdoc-editor-container.mobile .sdoc-editor-content.readonly .sdoc-article-container {
|
|
6
16
|
padding: 0;
|
|
7
17
|
width: auto;
|
|
@@ -13,12 +13,11 @@ import { getCursorPosition, getDomHeight, getDomMarginTop } from '../utils/dom-u
|
|
|
13
13
|
import EventBus from '../utils/event-bus';
|
|
14
14
|
import { ArticleContainer } from '../layout';
|
|
15
15
|
import { useScrollContext } from '../hooks/use-scroll-context';
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
16
|
+
var EditableArticle = function EditableArticle(_ref) {
|
|
17
|
+
var isShowComment = _ref.isShowComment,
|
|
18
|
+
editor = _ref.editor,
|
|
19
19
|
slateValue = _ref.slateValue,
|
|
20
|
-
|
|
21
|
-
isShowComment = _ref.isShowComment;
|
|
20
|
+
updateSlateValue = _ref.updateSlateValue;
|
|
22
21
|
var _useCursors = useCursors(editor),
|
|
23
22
|
cursors = _useCursors.cursors;
|
|
24
23
|
var decorate = usePipDecorate(editor);
|
|
@@ -28,10 +27,6 @@ var SlateEditor = function SlateEditor(_ref) {
|
|
|
28
27
|
var eventProxy = useMemo(function () {
|
|
29
28
|
return new EventProxy(editor);
|
|
30
29
|
}, []);
|
|
31
|
-
var onChange = useCallback(function (slateValue) {
|
|
32
|
-
setSlateValue(slateValue);
|
|
33
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
}, []);
|
|
35
30
|
var onMouseDown = useCallback(function (event) {
|
|
36
31
|
if (event.button === 0) {
|
|
37
32
|
editor.reSetTableSelectedRange();
|
|
@@ -135,12 +130,12 @@ var SlateEditor = function SlateEditor(_ref) {
|
|
|
135
130
|
return /*#__PURE__*/React.createElement(Slate, {
|
|
136
131
|
editor: editor,
|
|
137
132
|
value: slateValue,
|
|
138
|
-
onChange:
|
|
133
|
+
onChange: updateSlateValue
|
|
139
134
|
}, /*#__PURE__*/React.createElement(ArticleContainer, {
|
|
140
135
|
editor: editor
|
|
141
136
|
}, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ContextToolbar, null), /*#__PURE__*/React.createElement(SetNodeToDecorations, null), /*#__PURE__*/React.createElement(Editable, {
|
|
142
137
|
cursors: cursors,
|
|
143
|
-
renderElement:
|
|
138
|
+
renderElement: renderElement,
|
|
144
139
|
renderLeaf: renderLeaf,
|
|
145
140
|
onKeyDown: onKeyDown,
|
|
146
141
|
onMouseDown: onMouseDown,
|
|
@@ -148,7 +143,7 @@ var SlateEditor = function SlateEditor(_ref) {
|
|
|
148
143
|
onCut: eventProxy.onCut
|
|
149
144
|
})), /*#__PURE__*/React.createElement(SideToolbar, null), isShowComment && /*#__PURE__*/React.createElement(CommentContextProvider, null, /*#__PURE__*/React.createElement(CommentWrapper, null))));
|
|
150
145
|
};
|
|
151
|
-
|
|
146
|
+
EditableArticle.defaultProps = {
|
|
152
147
|
isShowComment: true
|
|
153
148
|
};
|
|
154
|
-
export default
|
|
149
|
+
export default EditableArticle;
|
|
@@ -2,24 +2,19 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import React, { useMemo, useEffect, useState, useCallback, useImperativeHandle, forwardRef } from 'react';
|
|
4
4
|
import deepCopy from 'deep-copy';
|
|
5
|
-
import { createDefaultEditor, renderElement } from '../extension';
|
|
6
|
-
import { withSocketIO } from '../socket';
|
|
7
|
-
import withNodeId from '../node-id';
|
|
8
|
-
import { PAGE_EDIT_AREA_WIDTH } from '../constants';
|
|
9
|
-
import { MODE } from '../../constants';
|
|
10
|
-
import DiffViewer from '../views/diff-viewer';
|
|
11
|
-
import SDocEditor from './common-editor';
|
|
12
|
-
import CommonLoading from '../../components/common-loading';
|
|
13
5
|
import context from '../../context';
|
|
6
|
+
import CommonLoading from '../../components/common-loading';
|
|
7
|
+
import { PAGE_EDIT_AREA_WIDTH } from '../constants';
|
|
8
|
+
import { createDefaultEditor } from '../extension';
|
|
9
|
+
import withNodeId from '../node-id';
|
|
10
|
+
import { withSocketIO } from '../socket';
|
|
11
|
+
import SDocEditor from './sdoc-editor';
|
|
14
12
|
import './index.css';
|
|
15
13
|
var Editor = forwardRef(function (_ref, ref) {
|
|
16
|
-
var
|
|
17
|
-
document = _ref.document,
|
|
18
|
-
setDiffChanges = _ref.setDiffChanges;
|
|
14
|
+
var document = _ref.document;
|
|
19
15
|
var editor = useMemo(function () {
|
|
20
16
|
var defaultEditor = createDefaultEditor();
|
|
21
17
|
var editorConfig = context.getEditorConfig();
|
|
22
|
-
defaultEditor.mode = MODE.EDITOR;
|
|
23
18
|
var newEditor = withNodeId(withSocketIO(defaultEditor, {
|
|
24
19
|
document: document,
|
|
25
20
|
config: editorConfig
|
|
@@ -31,22 +26,14 @@ var Editor = forwardRef(function (_ref, ref) {
|
|
|
31
26
|
|
|
32
27
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
28
|
}, []);
|
|
34
|
-
var _useState = useState(
|
|
29
|
+
var _useState = useState(false),
|
|
35
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var _useState3 = useState(
|
|
31
|
+
isLoading = _useState2[0],
|
|
32
|
+
_setLoading = _useState2[1];
|
|
33
|
+
var _useState3 = useState(document.children),
|
|
39
34
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _useState5 = useState(null),
|
|
43
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
-
diffContent = _useState6[0],
|
|
45
|
-
_setDiffContent = _useState6[1];
|
|
46
|
-
var _useState7 = useState(null),
|
|
47
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
48
|
-
currentContent = _useState8[0],
|
|
49
|
-
setCurrentContent = _useState8[1];
|
|
35
|
+
slateValue = _useState4[0],
|
|
36
|
+
_setSlateValue = _useState4[1];
|
|
50
37
|
|
|
51
38
|
// useMount: init socket connection
|
|
52
39
|
useEffect(function () {
|
|
@@ -70,20 +57,6 @@ var Editor = forwardRef(function (_ref, ref) {
|
|
|
70
57
|
setLoading: function setLoading(isLoading) {
|
|
71
58
|
_setLoading(isLoading);
|
|
72
59
|
},
|
|
73
|
-
setDiffContent: function setDiffContent(content) {
|
|
74
|
-
setCurrentContent(deepCopy(_objectSpread(_objectSpread({}, document), {}, {
|
|
75
|
-
children: slateValue
|
|
76
|
-
})));
|
|
77
|
-
_setDiffContent(content);
|
|
78
|
-
},
|
|
79
|
-
setEditorMode: function setEditorMode(mode) {
|
|
80
|
-
editor.cursors = {};
|
|
81
|
-
editor.selection = null;
|
|
82
|
-
if (mode === MODE.EDITOR) {
|
|
83
|
-
editor.operations = [];
|
|
84
|
-
}
|
|
85
|
-
editor.mode = mode;
|
|
86
|
-
},
|
|
87
60
|
setSlateValue: function setSlateValue(document) {
|
|
88
61
|
_setSlateValue(document.children);
|
|
89
62
|
},
|
|
@@ -105,21 +78,10 @@ var Editor = forwardRef(function (_ref, ref) {
|
|
|
105
78
|
className: "h-100 w-100 d-flex align-items-center justify-content-center"
|
|
106
79
|
}, /*#__PURE__*/React.createElement(CommonLoading, null));
|
|
107
80
|
}
|
|
108
|
-
if (mode === MODE.DIFF_VIEWER) {
|
|
109
|
-
return /*#__PURE__*/React.createElement(DiffViewer, {
|
|
110
|
-
showToolbar: true,
|
|
111
|
-
showOutline: true,
|
|
112
|
-
editor: editor,
|
|
113
|
-
currentContent: currentContent,
|
|
114
|
-
lastContent: diffContent,
|
|
115
|
-
didMountCallback: setDiffChanges
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
81
|
return /*#__PURE__*/React.createElement(SDocEditor, {
|
|
119
82
|
slateValue: slateValue,
|
|
120
83
|
editor: editor,
|
|
121
|
-
updateSlateValue: updateSlateValue
|
|
122
|
-
renderElement: renderElement
|
|
84
|
+
updateSlateValue: updateSlateValue
|
|
123
85
|
});
|
|
124
86
|
});
|
|
125
87
|
export default Editor;
|
|
@@ -3,13 +3,14 @@ import React, { useEffect } from 'react';
|
|
|
3
3
|
import { Editor } from '@seafile/slate';
|
|
4
4
|
import { focusEditor } from '../extension/core';
|
|
5
5
|
import { EditorContainer, EditorContent } from '../layout';
|
|
6
|
-
import SlateEditor from './slate-editor';
|
|
7
6
|
import InsertElementDialog from '../extension/commons/insert-element-dialog';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import EditableArticle from './editable-article';
|
|
8
|
+
import { ColorProvider } from '../hooks/use-color-context';
|
|
9
|
+
import { HeaderToolbar } from '../extension';
|
|
10
|
+
var SdocEditor = function SdocEditor(_ref) {
|
|
11
|
+
var editor = _ref.editor,
|
|
12
|
+
slateValue = _ref.slateValue,
|
|
13
|
+
updateSlateValue = _ref.updateSlateValue;
|
|
13
14
|
// useMount: focus editor
|
|
14
15
|
useEffect(function () {
|
|
15
16
|
var timer = setTimeout(function () {
|
|
@@ -35,16 +36,17 @@ var CommonEditor = function CommonEditor(_ref) {
|
|
|
35
36
|
}, []);
|
|
36
37
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
|
|
37
38
|
editor: editor
|
|
38
|
-
}, /*#__PURE__*/React.createElement(
|
|
39
|
+
}, /*#__PURE__*/React.createElement(ColorProvider, null, /*#__PURE__*/React.createElement(HeaderToolbar, {
|
|
40
|
+
editor: editor
|
|
41
|
+
}), /*#__PURE__*/React.createElement(EditorContent, {
|
|
39
42
|
docValue: slateValue,
|
|
40
43
|
showOutline: true
|
|
41
|
-
}, /*#__PURE__*/React.createElement(
|
|
44
|
+
}, /*#__PURE__*/React.createElement(EditableArticle, {
|
|
42
45
|
editor: editor,
|
|
43
46
|
slateValue: slateValue,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}))), /*#__PURE__*/React.createElement(InsertElementDialog, {
|
|
47
|
+
updateSlateValue: updateSlateValue
|
|
48
|
+
})))), /*#__PURE__*/React.createElement(InsertElementDialog, {
|
|
47
49
|
editor: editor
|
|
48
50
|
}));
|
|
49
51
|
};
|
|
50
|
-
export default
|
|
52
|
+
export default SdocEditor;
|
|
@@ -4,7 +4,7 @@ import { withHistory } from '@seafile/slate-history';
|
|
|
4
4
|
import Plugins from './plugins';
|
|
5
5
|
import renderElement from './render/render-element';
|
|
6
6
|
import renderLeaf from './render/render-leaf';
|
|
7
|
-
import {
|
|
7
|
+
import { HeaderToolbar, ContextToolbar, SideToolbar } from './toolbar';
|
|
8
8
|
var baseEditor = withHistory(withReact(createEditor()));
|
|
9
9
|
var defaultEditor = Plugins === null || Plugins === void 0 ? void 0 : Plugins.reduce(function (editor, pluginItem) {
|
|
10
10
|
var withPlugin = pluginItem.editorPlugin;
|
|
@@ -24,4 +24,4 @@ export var createDefaultEditor = function createDefaultEditor() {
|
|
|
24
24
|
return defaultEditor;
|
|
25
25
|
};
|
|
26
26
|
export default defaultEditor;
|
|
27
|
-
export { renderLeaf, renderElement,
|
|
27
|
+
export { renderLeaf, renderElement, HeaderToolbar, ContextToolbar, SideToolbar };
|
|
@@ -14,6 +14,7 @@ import toaster from '../../../../components/toast';
|
|
|
14
14
|
import context from '../../../../context';
|
|
15
15
|
import { getErrorMsg } from '../../../../utils';
|
|
16
16
|
import imagePlaceholder from '../../../assets/images/image-placeholder.png';
|
|
17
|
+
import { ADDED_STYLE, DELETED_STYLE } from '../../constants';
|
|
17
18
|
var Image = /*#__PURE__*/function (_React$Component) {
|
|
18
19
|
_inherits(Image, _React$Component);
|
|
19
20
|
var _super = _createSuper(Image);
|
|
@@ -195,6 +196,23 @@ var SdocImage = withTranslation('sdoc-editor')(Image);
|
|
|
195
196
|
function renderImage(props, editor) {
|
|
196
197
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
197
198
|
var isSelected = useSelected();
|
|
199
|
+
|
|
200
|
+
// decorate diff-viewer
|
|
201
|
+
var element = props.element;
|
|
202
|
+
if (element.ADD || element.DELETE) {
|
|
203
|
+
var style = element.ADD ? ADDED_STYLE : DELETED_STYLE;
|
|
204
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
205
|
+
className: "d-inline-block p-1",
|
|
206
|
+
style: {
|
|
207
|
+
backgroundColor: style.computed_background_color,
|
|
208
|
+
width: 'fit-content',
|
|
209
|
+
height: 'fit-content'
|
|
210
|
+
}
|
|
211
|
+
}, /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
|
|
212
|
+
editor: editor,
|
|
213
|
+
isSelected: isSelected
|
|
214
|
+
})));
|
|
215
|
+
}
|
|
198
216
|
return /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
|
|
199
217
|
editor: editor,
|
|
200
218
|
isSelected: isSelected
|
|
@@ -13,7 +13,7 @@ import HistoryMenu from './redo-undo';
|
|
|
13
13
|
import Font from '../../plugins/font/menu';
|
|
14
14
|
import InsertToolbar from './insert-toolbar';
|
|
15
15
|
import ActiveTableMenu from '../../plugins/table/menu/active-table-menu';
|
|
16
|
-
var
|
|
16
|
+
var HeaderToolbar = function HeaderToolbar(_ref) {
|
|
17
17
|
var editor = _ref.editor,
|
|
18
18
|
readonly = _ref.readonly;
|
|
19
19
|
useSelectionUpdate();
|
|
@@ -59,7 +59,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
59
59
|
readonly: readonly
|
|
60
60
|
}));
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
HeaderToolbar.defaultProps = {
|
|
63
63
|
readonly: false
|
|
64
64
|
};
|
|
65
|
-
export default
|
|
65
|
+
export default HeaderToolbar;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import HeaderToolbar from './header-toolbar';
|
|
2
2
|
import ContextToolbar from './context-toolbar';
|
|
3
3
|
import SideToolbar from './side-toolbar';
|
|
4
|
-
export {
|
|
4
|
+
export { HeaderToolbar, ContextToolbar, SideToolbar };
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { ColorProvider } from '../hooks/use-color-context';
|
|
4
|
-
import { Toolbar } from '../extension';
|
|
2
|
+
import classNames from 'classnames';
|
|
5
3
|
import { isMobile } from '../../utils';
|
|
6
4
|
import '../assets/css/default.css';
|
|
7
5
|
import '../assets/css/layout.css';
|
|
8
6
|
import '../assets/css/sdoc-editor-plugins.css';
|
|
9
7
|
import '../assets/css/dropdown-menu.css';
|
|
10
8
|
var EditorContainer = function EditorContainer(_ref) {
|
|
11
|
-
var
|
|
12
|
-
readonly = _ref.readonly
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
readonly = _ref.readonly;
|
|
11
|
+
var className = classNames('sdoc-editor-container', {
|
|
12
|
+
'mobile': isMobile,
|
|
13
|
+
'readonly': readonly
|
|
14
|
+
});
|
|
15
15
|
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
-
className:
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
}, /*#__PURE__*/React.createElement(ColorProvider, null, showToolbar && /*#__PURE__*/React.createElement(Toolbar, {
|
|
20
|
-
editor: editor,
|
|
21
|
-
readonly: readonly
|
|
22
|
-
}), children));
|
|
23
|
-
};
|
|
24
|
-
EditorContainer.defaultProps = {
|
|
25
|
-
showToolbar: true
|
|
16
|
+
className: className
|
|
17
|
+
}, children);
|
|
26
18
|
};
|
|
27
19
|
export default EditorContainer;
|
|
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import React, { useRef, useState, useCallback } from 'react';
|
|
3
3
|
import { ScrollContext } from '../hooks/use-scroll-context';
|
|
4
4
|
import SDocOutline from '../outline';
|
|
5
|
+
import classNames from 'classnames';
|
|
5
6
|
var EditorContent = function EditorContent(_ref) {
|
|
6
7
|
var readonly = _ref.readonly,
|
|
7
8
|
showOutline = _ref.showOutline,
|
|
@@ -16,22 +17,13 @@ var EditorContent = function EditorContent(_ref) {
|
|
|
16
17
|
var scrollLeft = event.target.scrollLeft;
|
|
17
18
|
setScrollLeft(scrollLeft);
|
|
18
19
|
}, []);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ref: scrollRef,
|
|
24
|
-
className: "sdoc-scroll-container",
|
|
25
|
-
id: "sdoc-scroll-container"
|
|
26
|
-
}, /*#__PURE__*/React.createElement(ScrollContext.Provider, {
|
|
27
|
-
value: {
|
|
28
|
-
scrollRef: scrollRef
|
|
29
|
-
}
|
|
30
|
-
}, children)));
|
|
31
|
-
}
|
|
20
|
+
var className = classNames('sdoc-editor-content', {
|
|
21
|
+
'readonly': readonly,
|
|
22
|
+
'no-outline': !showOutline
|
|
23
|
+
});
|
|
32
24
|
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
-
className:
|
|
34
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: className
|
|
26
|
+
}, showOutline && /*#__PURE__*/React.createElement("div", {
|
|
35
27
|
className: "sdoc-absolute-wrapper"
|
|
36
28
|
}, /*#__PURE__*/React.createElement(SDocOutline, {
|
|
37
29
|
scrollLeft: scrollLeft,
|
|
@@ -4,7 +4,6 @@ import { Editor, Operation } from '@seafile/slate';
|
|
|
4
4
|
import { getNode } from '../extension/core';
|
|
5
5
|
import * as OPERATION from '../node-id/constants';
|
|
6
6
|
import { setCursor } from '../cursor/helper';
|
|
7
|
-
import { MODE } from '../../constants';
|
|
8
7
|
export var getNodePathById = function getNodePathById(rootNode, nodeId) {
|
|
9
8
|
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
10
9
|
if (rootNode.id === nodeId) return path;
|
|
@@ -253,7 +252,6 @@ export var reExecRevertOperationList = function reExecRevertOperationList(editor
|
|
|
253
252
|
}
|
|
254
253
|
};
|
|
255
254
|
export var syncRemoteOperations = function syncRemoteOperations(editor, remoteOperations) {
|
|
256
|
-
if (editor.mode !== MODE.EDITOR) return;
|
|
257
255
|
if (remoteOperations.length === 0) return;
|
|
258
256
|
Editor.withoutNormalizing(editor, function () {
|
|
259
257
|
for (var i = 0; i < remoteOperations.length; i++) {
|
|
@@ -7,7 +7,7 @@ import { syncRemoteOperations, reExecRevertOperationList, revertOperationList, s
|
|
|
7
7
|
import SocketClient from './socket-client';
|
|
8
8
|
import { clientDebug, conflictDebug, serverDebug, stateDebug } from '../utils/debug';
|
|
9
9
|
import { deleteCursor } from '../cursor/helper';
|
|
10
|
-
import { EXTERNAL_EVENT
|
|
10
|
+
import { EXTERNAL_EVENT } from '../../constants';
|
|
11
11
|
|
|
12
12
|
// idle --> sending --> conflict --> idle
|
|
13
13
|
// --> conflict --> idle
|
|
@@ -56,7 +56,6 @@ var SocketManager = /*#__PURE__*/_createClass(function SocketManager(editor, _do
|
|
|
56
56
|
_this.sendOperations();
|
|
57
57
|
};
|
|
58
58
|
this.sendOperations = function () {
|
|
59
|
-
if (_this.editor.mode !== MODE.EDITOR) return;
|
|
60
59
|
if (_this.state !== STATE.IDLE) return;
|
|
61
60
|
stateDebug("State changed: ".concat(_this.state, " -> ").concat(STATE.SENDING));
|
|
62
61
|
_this.state = STATE.SENDING;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MODE } from '../../constants';
|
|
2
1
|
import { generateCursorData } from '../cursor/helper';
|
|
3
2
|
import EventBus from '../utils/event-bus';
|
|
4
3
|
import SocketManager from './socket-manager';
|
|
@@ -22,7 +21,6 @@ var withSocketIO = function withSocketIO(editor, options) {
|
|
|
22
21
|
newEditor.onChange = function () {
|
|
23
22
|
var document = options.document,
|
|
24
23
|
config = options.config;
|
|
25
|
-
if (newEditor.mode === MODE.DIFF_VIEWER) return;
|
|
26
24
|
var operations = newEditor.operations;
|
|
27
25
|
if (!newEditor.isRemote && operations.length > 0) {
|
|
28
26
|
var isAllSetSelection = operations.every(function (operation) {
|
|
@@ -30,23 +28,18 @@ var withSocketIO = function withSocketIO(editor, options) {
|
|
|
30
28
|
});
|
|
31
29
|
var _socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
32
30
|
if (!isAllSetSelection) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_socketManager.onReceiveLocalOperations(updateOperations);
|
|
39
|
-
}
|
|
31
|
+
// get update content value operations
|
|
32
|
+
var updateOperations = operations.filter(function (operation) {
|
|
33
|
+
return operation.type !== 'set_selection';
|
|
34
|
+
});
|
|
35
|
+
_socketManager.onReceiveLocalOperations(updateOperations);
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
_socketManager.sendCursorLocation(editor.selection);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (newEditor.mode === MODE.EDITOR) {
|
|
46
|
-
// dispatch editor change event
|
|
47
|
-
var eventBus = EventBus.getInstance(newEditor, document, config);
|
|
48
|
-
eventBus.dispatch('change');
|
|
37
|
+
_socketManager.sendCursorLocation(editor.selection);
|
|
49
38
|
}
|
|
39
|
+
|
|
40
|
+
// dispatch editor change event
|
|
41
|
+
var eventBus = EventBus.getInstance(newEditor, document, config);
|
|
42
|
+
eventBus.dispatch('change');
|
|
50
43
|
onChange();
|
|
51
44
|
};
|
|
52
45
|
newEditor.rebaseContent = function (document, originFileVersion) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import SDocViewer from './sdoc-viewer';
|
|
2
|
+
import DiffViewer from './sdoc-diff-viewer';
|
|
3
|
+
import RevisionDiffViewer from './revision-diff-viewer';
|
|
4
|
+
export { SDocViewer, DiffViewer, RevisionDiffViewer };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { Editable, Slate } from '@seafile/slate-react';
|
|
3
|
+
import { ArticleContainer } from '../layout';
|
|
4
|
+
import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
|
|
5
|
+
import { renderElement, renderLeaf } from '../extension';
|
|
6
|
+
import { usePipDecorate } from '../decorates';
|
|
7
|
+
export default function ReadOnlyArticle(_ref) {
|
|
8
|
+
var editor = _ref.editor,
|
|
9
|
+
slateValue = _ref.slateValue;
|
|
10
|
+
var decorate = usePipDecorate(editor);
|
|
11
|
+
return /*#__PURE__*/React.createElement(Slate, {
|
|
12
|
+
editor: editor,
|
|
13
|
+
value: slateValue
|
|
14
|
+
}, /*#__PURE__*/React.createElement(ArticleContainer, {
|
|
15
|
+
editor: editor,
|
|
16
|
+
readOnly: true
|
|
17
|
+
}, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(SetNodeToDecorations, null), /*#__PURE__*/React.createElement(Editable, {
|
|
18
|
+
readOnly: true,
|
|
19
|
+
placeholder: "",
|
|
20
|
+
renderElement: renderElement,
|
|
21
|
+
renderLeaf: renderLeaf,
|
|
22
|
+
decorate: decorate
|
|
23
|
+
}))));
|
|
24
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import context from '../../context';
|
|
4
|
+
import { getDiff } from '../utils/diff';
|
|
5
|
+
import SDocViewer from './sdoc-viewer';
|
|
6
|
+
import Loading from '../../components/loading';
|
|
7
|
+
import '../../assets/css/diff-viewer.css';
|
|
8
|
+
var RevisionDiffViewer = function RevisionDiffViewer(_ref) {
|
|
9
|
+
var revisionContent = _ref.revisionContent,
|
|
10
|
+
didMountCallback = _ref.didMountCallback;
|
|
11
|
+
var _useState = useState(true),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
isLoading = _useState2[0],
|
|
14
|
+
setIsLoading = _useState2[1];
|
|
15
|
+
var _useState3 = useState(null),
|
|
16
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
17
|
+
diff = _useState4[0],
|
|
18
|
+
setDiff = _useState4[1];
|
|
19
|
+
useEffect(function () {
|
|
20
|
+
setIsLoading(true);
|
|
21
|
+
context.getSeadocOriginFileContent().then(function (res) {
|
|
22
|
+
var originContentString = res.data.content;
|
|
23
|
+
var originContent = JSON.parse(originContentString);
|
|
24
|
+
var diff = getDiff(revisionContent, originContent);
|
|
25
|
+
setDiff(diff);
|
|
26
|
+
didMountCallback && didMountCallback(diff);
|
|
27
|
+
setIsLoading(false);
|
|
28
|
+
}).catch(function (error) {
|
|
29
|
+
console.log('error');
|
|
30
|
+
setIsLoading(false);
|
|
31
|
+
});
|
|
32
|
+
}, [revisionContent, didMountCallback]);
|
|
33
|
+
if (isLoading) {
|
|
34
|
+
return /*#__PURE__*/React.createElement(Loading, null);
|
|
35
|
+
}
|
|
36
|
+
return /*#__PURE__*/React.createElement(SDocViewer, {
|
|
37
|
+
showToolbar: true,
|
|
38
|
+
showOutline: true,
|
|
39
|
+
document: {
|
|
40
|
+
children: diff.value
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export default RevisionDiffViewer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getDiff } from '../utils/diff';
|
|
3
|
+
import SDocViewer from './sdoc-viewer';
|
|
4
|
+
import '../../assets/css/diff-viewer.css';
|
|
5
|
+
var DiffViewer = function DiffViewer(_ref) {
|
|
6
|
+
var currentContent = _ref.currentContent,
|
|
7
|
+
lastContent = _ref.lastContent;
|
|
8
|
+
var diff = getDiff(currentContent, lastContent);
|
|
9
|
+
return /*#__PURE__*/React.createElement(SDocViewer, {
|
|
10
|
+
showToolbar: false,
|
|
11
|
+
showOutline: false,
|
|
12
|
+
document: {
|
|
13
|
+
children: diff.value
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default DiffViewer;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HeaderToolbar, createDefaultEditor } from '../extension';
|
|
3
|
+
import withNodeId from '../node-id';
|
|
4
|
+
import { generateDefaultDocContent } from '../../utils';
|
|
5
|
+
import { EditorContainer, EditorContent } from '../layout';
|
|
6
|
+
import ReadOnlyArticle from './readonly-article';
|
|
7
|
+
import { ColorProvider } from '../hooks/use-color-context';
|
|
8
|
+
import '../assets/css/simple-viewer.css';
|
|
9
|
+
var SDocViewer = function SDocViewer(_ref) {
|
|
10
|
+
var editor = _ref.editor,
|
|
11
|
+
document = _ref.document,
|
|
12
|
+
showToolbar = _ref.showToolbar,
|
|
13
|
+
showOutline = _ref.showOutline;
|
|
14
|
+
var validEditor = editor || withNodeId(createDefaultEditor());
|
|
15
|
+
var slateValue = (document || generateDefaultDocContent()).children;
|
|
16
|
+
return /*#__PURE__*/React.createElement(EditorContainer, {
|
|
17
|
+
editor: validEditor,
|
|
18
|
+
readonly: true
|
|
19
|
+
}, /*#__PURE__*/React.createElement(ColorProvider, null, showToolbar && /*#__PURE__*/React.createElement(HeaderToolbar, {
|
|
20
|
+
editor: validEditor,
|
|
21
|
+
readonly: true
|
|
22
|
+
}), /*#__PURE__*/React.createElement(EditorContent, {
|
|
23
|
+
docValue: slateValue,
|
|
24
|
+
readonly: true,
|
|
25
|
+
showOutline: showOutline
|
|
26
|
+
}, /*#__PURE__*/React.createElement(ReadOnlyArticle, {
|
|
27
|
+
editor: validEditor,
|
|
28
|
+
slateValue: slateValue
|
|
29
|
+
}))));
|
|
30
|
+
};
|
|
31
|
+
SDocViewer.defaultProps = {
|
|
32
|
+
showToolbar: false,
|
|
33
|
+
showOutline: false
|
|
34
|
+
};
|
|
35
|
+
export default SDocViewer;
|
package/dist/constants/index.js
CHANGED
|
@@ -14,11 +14,6 @@ export var EXTERNAL_EVENT = {
|
|
|
14
14
|
REMOVE_DOCUMENT: 'remove_document',
|
|
15
15
|
REMOVE_DOCUMENT_ERROR: 'remove_document_error'
|
|
16
16
|
};
|
|
17
|
-
export var MODE = {
|
|
18
|
-
DIFF_VIEWER: 'diff_viewer',
|
|
19
|
-
VIEWER: 'viewer',
|
|
20
|
-
EDITOR: 'editor'
|
|
21
|
-
};
|
|
22
17
|
export var TIP_TYPE = {
|
|
23
18
|
DELETE_NO_CHANGES_REVISION: 'delete_no_changes_revision',
|
|
24
19
|
MERGE: 'merge',
|
|
@@ -11,10 +11,11 @@ import { generateDefaultDocContent } from '../utils';
|
|
|
11
11
|
import context from '../context';
|
|
12
12
|
import ErrorBoundary from './error-boundary';
|
|
13
13
|
import TipDialog from '../components/tip-dialog';
|
|
14
|
-
import { EXTERNAL_EVENT,
|
|
14
|
+
import { EXTERNAL_EVENT, TIP_TYPE, REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../constants';
|
|
15
15
|
import { getRebase, hasConflict } from '../basic-sdk/utils/rebase';
|
|
16
16
|
import toaster from '../components/toast';
|
|
17
17
|
import { EventBus, SDocEditor } from '../basic-sdk';
|
|
18
|
+
import { RevisionDiffViewer } from '../basic-sdk/views';
|
|
18
19
|
import '../assets/css/simple-editor.css';
|
|
19
20
|
var SimpleEditor = function SimpleEditor(_ref) {
|
|
20
21
|
var isStarred = _ref.isStarred,
|
|
@@ -36,12 +37,12 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
36
37
|
setShowChanges = _useState6[1];
|
|
37
38
|
var _useState7 = useState(null),
|
|
38
39
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var _useState9 = useState(
|
|
40
|
+
revisionContent = _useState8[0],
|
|
41
|
+
setRevisionContent = _useState8[1];
|
|
42
|
+
var _useState9 = useState(null),
|
|
42
43
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
document = _useState10[0],
|
|
45
|
+
setDocument = _useState10[1];
|
|
45
46
|
var _useState11 = useState([]),
|
|
46
47
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
47
48
|
changes = _useState12[0],
|
|
@@ -166,32 +167,11 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
166
167
|
errorCallback && errorCallback(errorMessage);
|
|
167
168
|
});
|
|
168
169
|
}, []);
|
|
169
|
-
var setDiffContent = useCallback(function () {
|
|
170
|
-
context.getSeadocOriginFileContent().then(function (res) {
|
|
171
|
-
var originContentString = res.data.content;
|
|
172
|
-
var originContent = JSON.parse(originContentString);
|
|
173
|
-
editorRef.current.setDiffContent(originContent);
|
|
174
|
-
editorRef.current.setLoading(false);
|
|
175
|
-
}).catch(function (error) {
|
|
176
|
-
console.log('error');
|
|
177
|
-
});
|
|
178
|
-
}, []);
|
|
179
170
|
var toggleViewChanges = useCallback(function (isShowChanges) {
|
|
180
|
-
var revisionContent = editorRef.current.getSlateValue();
|
|
181
|
-
if (isShowChanges && hasConflict(revisionContent.children)) {
|
|
182
|
-
setTipType(TIP_TYPE.HAS_CONFLICT_BEFORE_VIEW_CHANGES);
|
|
183
|
-
setShowTip(true);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
editorRef.current.setLoading(true);
|
|
187
|
-
setShowChanges(isShowChanges);
|
|
188
|
-
var mode = isShowChanges ? MODE.DIFF_VIEWER : MODE.EDITOR;
|
|
189
|
-
setMode(mode);
|
|
190
|
-
editorRef.current.setEditorMode(mode);
|
|
191
171
|
if (!isShowChanges) {
|
|
192
172
|
loadDocument(function (document) {
|
|
193
173
|
setDocument(document);
|
|
194
|
-
|
|
174
|
+
setShowChanges(isShowChanges);
|
|
195
175
|
editorRef.current.setLoading(false);
|
|
196
176
|
}, function (errorMessage) {
|
|
197
177
|
setErrorMessage(errorMessage);
|
|
@@ -199,10 +179,26 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
199
179
|
});
|
|
200
180
|
return;
|
|
201
181
|
}
|
|
202
|
-
setDiffContent();
|
|
203
182
|
|
|
183
|
+
// Get the contents of the current revision
|
|
184
|
+
var revisionContent = editorRef.current.getSlateValue();
|
|
185
|
+
|
|
186
|
+
// Prevent users from switching if document contains conflicting content
|
|
187
|
+
if (hasConflict(revisionContent.children)) {
|
|
188
|
+
setTipType(TIP_TYPE.HAS_CONFLICT_BEFORE_VIEW_CHANGES);
|
|
189
|
+
setShowTip(true);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Record the contents of the current revision
|
|
194
|
+
setRevisionContent(revisionContent);
|
|
195
|
+
setShowChanges(isShowChanges);
|
|
204
196
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
205
197
|
}, [document, editorRef.current]);
|
|
198
|
+
var setDiffChanges = useCallback(function (diff) {
|
|
199
|
+
setChanges(diff.changes);
|
|
200
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
201
|
+
}, [isShowChanges]);
|
|
206
202
|
var publishRevision = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
207
203
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
208
204
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -260,12 +256,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
260
256
|
return _context.stop();
|
|
261
257
|
}
|
|
262
258
|
}, _callee);
|
|
263
|
-
})), [isShowChanges
|
|
264
|
-
var setDiffChanges = useCallback(function (diff) {
|
|
265
|
-
setChanges(diff.changes);
|
|
266
|
-
|
|
267
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
268
|
-
}, [isShowChanges]);
|
|
259
|
+
})), [isShowChanges]);
|
|
269
260
|
var jumpToURL = useCallback(function (url) {
|
|
270
261
|
window.location.href = url;
|
|
271
262
|
}, []);
|
|
@@ -305,11 +296,13 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
305
296
|
context.updateSettings({
|
|
306
297
|
'originFileVersion': origin_file_version
|
|
307
298
|
});
|
|
299
|
+
// if revision diff view change to sdoc editor
|
|
300
|
+
if (isShowChanges) {
|
|
301
|
+
setShowChanges(false);
|
|
302
|
+
}
|
|
308
303
|
editorRef.current.setLoading(true);
|
|
309
304
|
editorRef.current.setSlateValue(mergeValue);
|
|
310
305
|
editorRef.current.updateDocumentVersion(mergeValue);
|
|
311
|
-
setMode(MODE.EDITOR);
|
|
312
|
-
editorRef.current.setEditorMode(MODE.EDITOR);
|
|
313
306
|
editorRef.current.setLoading(false);
|
|
314
307
|
setShowTip(false);
|
|
315
308
|
}).catch(function (error) {
|
|
@@ -341,11 +334,12 @@ var SimpleEditor = function SimpleEditor(_ref) {
|
|
|
341
334
|
changes: changes,
|
|
342
335
|
toggleViewChanges: toggleViewChanges,
|
|
343
336
|
publishRevision: publishRevision
|
|
344
|
-
})), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(SDocEditor, {
|
|
337
|
+
})), /*#__PURE__*/React.createElement(Content, null, !isShowChanges && /*#__PURE__*/React.createElement(SDocEditor, {
|
|
345
338
|
ref: editorRef,
|
|
346
|
-
document: document
|
|
347
|
-
|
|
348
|
-
|
|
339
|
+
document: document
|
|
340
|
+
}), isShowChanges && /*#__PURE__*/React.createElement(RevisionDiffViewer, {
|
|
341
|
+
revisionContent: revisionContent,
|
|
342
|
+
componentDidCallback: setDiffChanges
|
|
349
343
|
}))), showTip && /*#__PURE__*/React.createElement(TipDialog, {
|
|
350
344
|
toggle: closeTip,
|
|
351
345
|
submit: tipSubmit,
|
package/package.json
CHANGED
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "Link file",
|
|
368
368
|
"Keep_my_modification": "Keep my modification",
|
|
369
369
|
"Keep_other_modification": "Keep other's modification",
|
|
370
|
-
"Keep_both_modification": "Keep
|
|
370
|
+
"Keep_both_modification": "Keep both modification",
|
|
371
371
|
"Tip": "Tip",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
|
|
373
373
|
"Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "Link file",
|
|
368
368
|
"Keep_my_modification": "Keep my modification",
|
|
369
369
|
"Keep_other_modification": "Keep other's modification",
|
|
370
|
-
"Keep_both_modification": "Keep
|
|
370
|
+
"Keep_both_modification": "Keep both modification",
|
|
371
371
|
"Tip": "Tip",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
|
|
373
373
|
"Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "Link file",
|
|
368
368
|
"Keep_my_modification": "Keep my modification",
|
|
369
369
|
"Keep_other_modification": "Keep other's modification",
|
|
370
|
-
"Keep_both_modification": "Keep
|
|
370
|
+
"Keep_both_modification": "Keep both modification",
|
|
371
371
|
"Tip": "Tip",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
|
|
373
373
|
"Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "Link file",
|
|
368
368
|
"Keep_my_modification": "Keep my modification",
|
|
369
369
|
"Keep_other_modification": "Keep other's modification",
|
|
370
|
-
"Keep_both_modification": "Keep
|
|
370
|
+
"Keep_both_modification": "Keep both modification",
|
|
371
371
|
"Tip": "Tip",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
|
|
373
373
|
"Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "Link file",
|
|
368
368
|
"Keep_my_modification": "Keep my modification",
|
|
369
369
|
"Keep_other_modification": "Keep other's modification",
|
|
370
|
-
"Keep_both_modification": "Keep
|
|
370
|
+
"Keep_both_modification": "Keep both modification",
|
|
371
371
|
"Tip": "Tip",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
|
|
373
373
|
"Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "Link file",
|
|
368
368
|
"Keep_my_modification": "Keep my modification",
|
|
369
369
|
"Keep_other_modification": "Keep other's modification",
|
|
370
|
-
"Keep_both_modification": "Keep
|
|
370
|
+
"Keep_both_modification": "Keep both modification",
|
|
371
371
|
"Tip": "Tip",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
|
|
373
373
|
"Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "Ссылка на файл",
|
|
368
368
|
"Keep_my_modification": "Сохранить мою модификацию",
|
|
369
369
|
"Keep_other_modification": "Сохранить чужую модификацию",
|
|
370
|
-
"Keep_both_modification": "
|
|
370
|
+
"Keep_both_modification": "Keep both modification",
|
|
371
371
|
"Tip": "Совет",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "Редакция не внесла никаких изменений по сравнению с исходным документом. Вы хотите удалить эту редакцию?",
|
|
373
373
|
"Has_been_replaced_tip": "Содержимое документа было заменено. Обновите страницу.",
|
|
@@ -376,7 +376,7 @@
|
|
|
376
376
|
"Merge_tip": "В документах есть конфликты. Вы хотите объединить их?",
|
|
377
377
|
"Has_conflict_before_view_changes_tip": "В документе есть конфликты. Разрешите конфликт перед просмотром изменений!",
|
|
378
378
|
"Has_been_removed_tip": "Документ удален, посмотрите другие документы.",
|
|
379
|
-
"Revision_created": "
|
|
380
|
-
"Checking": "
|
|
381
|
-
"Publishing": "
|
|
379
|
+
"Revision_created": "Версия {{id}} создана",
|
|
380
|
+
"Checking": "Проверка...",
|
|
381
|
+
"Publishing": "Публикация..."
|
|
382
382
|
}
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
"Link_file": "文件链接",
|
|
368
368
|
"Keep_my_modification": "保留我的更改",
|
|
369
369
|
"Keep_other_modification": "保留其他的更改",
|
|
370
|
-
"Keep_both_modification": "
|
|
370
|
+
"Keep_both_modification": "保留两者更改",
|
|
371
371
|
"Tip": "提示",
|
|
372
372
|
"Rebase_delete_no_change_revision_tip": "修订改没有更改,是否删除修订稿?",
|
|
373
373
|
"Has_been_replaced_tip": "文档内容已经被替换,请刷新页面。",
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect } from 'react';
|
|
2
|
-
import { renderLeaf, renderElement } from '../extension';
|
|
3
|
-
import { getDiff } from '../utils/diff';
|
|
4
|
-
import context from '../../context';
|
|
5
|
-
import { ELEMENT_TYPE, ADDED_STYLE, DELETED_STYLE } from '../extension/constants';
|
|
6
|
-
import SDocViewer from './viewer';
|
|
7
|
-
import '../../assets/css/diff-viewer.css';
|
|
8
|
-
var DiffViewer = function DiffViewer(_ref) {
|
|
9
|
-
var editor = _ref.editor,
|
|
10
|
-
currentContent = _ref.currentContent,
|
|
11
|
-
lastContent = _ref.lastContent,
|
|
12
|
-
didMountCallback = _ref.didMountCallback,
|
|
13
|
-
showToolbar = _ref.showToolbar,
|
|
14
|
-
showOutline = _ref.showOutline;
|
|
15
|
-
var diff = getDiff(currentContent, lastContent);
|
|
16
|
-
context.initSettings();
|
|
17
|
-
useEffect(function () {
|
|
18
|
-
didMountCallback && didMountCallback(diff);
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
-
}, []);
|
|
22
|
-
var customRenderLeaf = useCallback(function (props, editor) {
|
|
23
|
-
return renderLeaf(props, editor);
|
|
24
|
-
}, []);
|
|
25
|
-
var customRenderElement = useCallback(function (props, editor) {
|
|
26
|
-
var element = props.element;
|
|
27
|
-
var type = element.type;
|
|
28
|
-
if (type === ELEMENT_TYPE.IMAGE && (element.ADD || element.DELETE)) {
|
|
29
|
-
var style = element.ADD ? ADDED_STYLE : DELETED_STYLE;
|
|
30
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
31
|
-
className: "d-inline-block p-1",
|
|
32
|
-
style: {
|
|
33
|
-
backgroundColor: style.computed_background_color,
|
|
34
|
-
width: 'fit-content',
|
|
35
|
-
height: 'fit-content'
|
|
36
|
-
}
|
|
37
|
-
}, renderElement(props, editor));
|
|
38
|
-
}
|
|
39
|
-
return renderElement(props, editor);
|
|
40
|
-
}, []);
|
|
41
|
-
return /*#__PURE__*/React.createElement(SDocViewer, {
|
|
42
|
-
editor: editor,
|
|
43
|
-
showToolbar: showToolbar,
|
|
44
|
-
showOutline: showOutline,
|
|
45
|
-
document: {
|
|
46
|
-
children: diff.value
|
|
47
|
-
},
|
|
48
|
-
renderLeaf: customRenderLeaf,
|
|
49
|
-
renderElement: customRenderElement
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
DiffViewer.defaultProps = {
|
|
53
|
-
showToolbar: false,
|
|
54
|
-
showOutline: false
|
|
55
|
-
};
|
|
56
|
-
export default DiffViewer;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, { Fragment } from 'react';
|
|
2
|
-
import { Editable, Slate } from '@seafile/slate-react';
|
|
3
|
-
import { renderLeaf as _renderLeaf, renderElement as _renderElement, createDefaultEditor } from '../extension';
|
|
4
|
-
import withNodeId from '../node-id';
|
|
5
|
-
import { generateDefaultDocContent } from '../../utils';
|
|
6
|
-
import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
|
|
7
|
-
import { usePipDecorate } from '../decorates';
|
|
8
|
-
import { ArticleContainer, EditorContainer, EditorContent } from '../layout';
|
|
9
|
-
import '../assets/css/simple-viewer.css';
|
|
10
|
-
var SDocViewer = function SDocViewer(_ref) {
|
|
11
|
-
var editor = _ref.editor,
|
|
12
|
-
document = _ref.document,
|
|
13
|
-
customRenderLeaf = _ref.renderLeaf,
|
|
14
|
-
customRenderElement = _ref.renderElement,
|
|
15
|
-
showToolbar = _ref.showToolbar,
|
|
16
|
-
showOutline = _ref.showOutline;
|
|
17
|
-
var validEditor = editor || withNodeId(createDefaultEditor());
|
|
18
|
-
var slateValue = (document || generateDefaultDocContent()).children;
|
|
19
|
-
var decorate = usePipDecorate(validEditor);
|
|
20
|
-
return /*#__PURE__*/React.createElement(EditorContainer, {
|
|
21
|
-
editor: validEditor,
|
|
22
|
-
showToolbar: showToolbar,
|
|
23
|
-
readonly: true
|
|
24
|
-
}, /*#__PURE__*/React.createElement(EditorContent, {
|
|
25
|
-
docValue: slateValue,
|
|
26
|
-
readonly: true,
|
|
27
|
-
showOutline: showOutline
|
|
28
|
-
}, /*#__PURE__*/React.createElement(Slate, {
|
|
29
|
-
editor: validEditor,
|
|
30
|
-
value: slateValue
|
|
31
|
-
}, /*#__PURE__*/React.createElement(ArticleContainer, {
|
|
32
|
-
editor: validEditor,
|
|
33
|
-
readOnly: true
|
|
34
|
-
}, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(SetNodeToDecorations, null), /*#__PURE__*/React.createElement(Editable, {
|
|
35
|
-
readOnly: true,
|
|
36
|
-
placeholder: "",
|
|
37
|
-
renderElement: function renderElement(props) {
|
|
38
|
-
return (customRenderElement || _renderElement)(props, validEditor);
|
|
39
|
-
},
|
|
40
|
-
renderLeaf: function renderLeaf(props) {
|
|
41
|
-
return (customRenderLeaf || _renderLeaf)(props, validEditor);
|
|
42
|
-
},
|
|
43
|
-
onDOMBeforeInput: function onDOMBeforeInput(event) {},
|
|
44
|
-
decorate: decorate
|
|
45
|
-
}))))));
|
|
46
|
-
};
|
|
47
|
-
SDocViewer.defaultProps = {
|
|
48
|
-
showToolbar: false,
|
|
49
|
-
showOutline: false
|
|
50
|
-
};
|
|
51
|
-
export default SDocViewer;
|