@seafile/sdoc-editor 0.1.154-beta5 → 0.1.155
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/api/seafile-api.js +9 -22
- package/dist/basic-sdk/comment/comment-decorate.js +1 -1
- package/dist/basic-sdk/constants/index.js +1 -25
- package/dist/basic-sdk/editor.js +105 -0
- package/dist/basic-sdk/extension/constants/color.js +2 -2
- package/dist/basic-sdk/extension/constants/diff-view.js +2 -2
- package/dist/basic-sdk/extension/constants/element-type.js +1 -6
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/constants/menus-config.js +0 -5
- package/dist/basic-sdk/extension/core/transforms/replace-node-children.js +0 -26
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +2 -2
- package/dist/basic-sdk/extension/plugins/sdoc-link/render-elem.js +2 -2
- package/dist/basic-sdk/extension/plugins/table/constants/index.js +3 -3
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/cell-bg-color-menu.js +13 -9
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +11 -11
- package/dist/basic-sdk/extension/plugins/text-style/render-elem.js +2 -2
- package/dist/basic-sdk/extension/render/render-element.js +1 -221
- package/dist/basic-sdk/hooks/use-color-context.js +10 -10
- package/dist/basic-sdk/{editor/slate-editor.js → slate-editor.js} +16 -21
- package/dist/basic-sdk/socket/helpers.js +0 -2
- package/dist/basic-sdk/socket/socket-client.js +0 -58
- package/dist/basic-sdk/socket/socket-manager.js +2 -34
- package/dist/basic-sdk/socket/with-socket-io.js +12 -35
- package/dist/basic-sdk/utils/diff.js +3 -4
- package/dist/basic-sdk/views/diff-viewer.js +2 -4
- package/dist/basic-sdk/views/viewer.js +12 -9
- package/dist/components/doc-operations/index.js +2 -4
- package/dist/components/doc-operations/revision-operations/index.js +2 -5
- package/dist/components/doc-operations/revision-operations/publish-button.js +13 -6
- package/dist/constants/index.js +2 -26
- package/dist/context.js +9 -37
- package/dist/pages/simple-editor.js +84 -251
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +1 -11
- package/public/locales/zh_CN/sdoc-editor.json +1 -10
- package/dist/basic-sdk/editor/common-editor.js +0 -50
- package/dist/basic-sdk/editor/index.css +0 -29
- package/dist/basic-sdk/editor/index.js +0 -129
- package/dist/basic-sdk/utils/rebase.js +0 -193
- package/dist/components/tip-dialog/index.js +0 -48
- package/dist/components/tip-dialog/tip-content.js +0 -47
package/package.json
CHANGED
|
@@ -364,15 +364,5 @@
|
|
|
364
364
|
"Title": "Title",
|
|
365
365
|
"Subtitle": "Subtitle",
|
|
366
366
|
"Link_sdoc": "Link sdoc",
|
|
367
|
-
"Link_file": "Link file"
|
|
368
|
-
"Keep_my_modification": "Keep my modification",
|
|
369
|
-
"Keep_other_modification": "Keep other's modification",
|
|
370
|
-
"Keep_both_modification": "Keep my modification",
|
|
371
|
-
"Tip": "Tip",
|
|
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
|
-
"Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
|
|
374
|
-
"Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
|
|
375
|
-
"Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
|
|
376
|
-
"Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
|
|
377
|
-
"Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!"
|
|
367
|
+
"Link_file": "Link file"
|
|
378
368
|
}
|
|
@@ -363,14 +363,5 @@
|
|
|
363
363
|
"No_changes": "没有变化",
|
|
364
364
|
"Title": "标题",
|
|
365
365
|
"Subtitle": "副标题",
|
|
366
|
-
"Link_sdoc": "链接 sdoc"
|
|
367
|
-
"Keep_my_modification": "保留我的更改",
|
|
368
|
-
"Keep_other_modification": "保留其他的更改",
|
|
369
|
-
"Keep_both_modification": "保留两个更改",
|
|
370
|
-
"Rebase_delete_no_change_revision_tip": "修订改没有更改,是否删除修订稿?",
|
|
371
|
-
"Has_been_replaced_tip": "文档内容已经被替换,请刷新页面。",
|
|
372
|
-
"Has_been_published_tip": "修订稿已经发布了,{{ time }} 秒后自动跳转到源文件。",
|
|
373
|
-
"Has_conflict_before_publish_tip": "文档有冲突,请解决冲突后再发布!",
|
|
374
|
-
"Merge_tip": "文档有冲突,是否合并?",
|
|
375
|
-
"Has_conflict_before_view_changes_tip": "文档有冲突,请解决冲突后再查看更改!"
|
|
366
|
+
"Link_sdoc": "链接 sdoc"
|
|
376
367
|
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
import { Editor } from '@seafile/slate';
|
|
4
|
-
import { focusEditor } from '../extension/core';
|
|
5
|
-
import { EditorContainer, EditorContent } from '../layout';
|
|
6
|
-
import SlateEditor from './slate-editor';
|
|
7
|
-
import InsertElementDialog from '../extension/commons/insert-element-dialog';
|
|
8
|
-
var CommonEditor = function CommonEditor(_ref) {
|
|
9
|
-
var slateValue = _ref.slateValue,
|
|
10
|
-
updateSlateValue = _ref.updateSlateValue,
|
|
11
|
-
editor = _ref.editor,
|
|
12
|
-
renderElement = _ref.renderElement;
|
|
13
|
-
// useMount: focus editor
|
|
14
|
-
useEffect(function () {
|
|
15
|
-
var timer = setTimeout(function () {
|
|
16
|
-
var _editor$children = _slicedToArray(editor.children, 1),
|
|
17
|
-
firstNode = _editor$children[0];
|
|
18
|
-
if (firstNode) {
|
|
19
|
-
var _firstNode$children = _slicedToArray(firstNode.children, 1),
|
|
20
|
-
firstNodeFirstChild = _firstNode$children[0];
|
|
21
|
-
if (firstNodeFirstChild) {
|
|
22
|
-
var endOfFirstNode = Editor.end(editor, [0, 0]);
|
|
23
|
-
var range = {
|
|
24
|
-
anchor: endOfFirstNode,
|
|
25
|
-
focus: endOfFirstNode
|
|
26
|
-
};
|
|
27
|
-
focusEditor(editor, range);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}, 300);
|
|
31
|
-
return function () {
|
|
32
|
-
clearTimeout(timer);
|
|
33
|
-
};
|
|
34
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
-
}, []);
|
|
36
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorContainer, {
|
|
37
|
-
editor: editor
|
|
38
|
-
}, /*#__PURE__*/React.createElement(EditorContent, {
|
|
39
|
-
docValue: slateValue,
|
|
40
|
-
showOutline: true
|
|
41
|
-
}, /*#__PURE__*/React.createElement(SlateEditor, {
|
|
42
|
-
editor: editor,
|
|
43
|
-
slateValue: slateValue,
|
|
44
|
-
setSlateValue: updateSlateValue,
|
|
45
|
-
renderElement: renderElement
|
|
46
|
-
}))), /*#__PURE__*/React.createElement(InsertElementDialog, {
|
|
47
|
-
editor: editor
|
|
48
|
-
}));
|
|
49
|
-
};
|
|
50
|
-
export default CommonEditor;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
.sdoc-rebase-btn-group {
|
|
2
|
-
color: #aaa;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.sdoc-rebase-btn-group .sdoc-rebase-btn {
|
|
6
|
-
cursor: pointer;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.sdoc-rebase-current-changes-start {
|
|
10
|
-
background-color: rgb(202, 232, 254);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.sdoc-rebase-current-changes {
|
|
14
|
-
background-color: rgba(202, 232, 254, .8);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.sdoc-rebase-incoming-changes {
|
|
18
|
-
background-color: rgb(222, 232, 254);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.sdoc-rebase-incoming-changes > *:first-child,
|
|
22
|
-
.sdoc-rebase-current-changes > *:first-child {
|
|
23
|
-
margin: 0;
|
|
24
|
-
padding: 0.8em 0 0.8em 0.2em;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.sdoc-rebase-incoming-changes-end {
|
|
28
|
-
background-color: rgb(212, 212, 254);
|
|
29
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import React, { useMemo, useEffect, useState, useCallback, useImperativeHandle, forwardRef } from 'react';
|
|
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
|
-
import context from '../../context';
|
|
14
|
-
import './index.css';
|
|
15
|
-
var Editor = forwardRef(function (_ref, ref) {
|
|
16
|
-
var mode = _ref.mode,
|
|
17
|
-
document = _ref.document,
|
|
18
|
-
setDiffChanges = _ref.setDiffChanges;
|
|
19
|
-
var editor = useMemo(function () {
|
|
20
|
-
var defaultEditor = createDefaultEditor();
|
|
21
|
-
var editorConfig = context.getEditorConfig();
|
|
22
|
-
defaultEditor.mode = MODE.EDITOR;
|
|
23
|
-
var newEditor = withNodeId(withSocketIO(defaultEditor, {
|
|
24
|
-
document: document,
|
|
25
|
-
config: editorConfig
|
|
26
|
-
}));
|
|
27
|
-
var cursors = document.cursors;
|
|
28
|
-
newEditor.cursors = cursors || {};
|
|
29
|
-
newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
|
|
30
|
-
return newEditor;
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
-
}, []);
|
|
34
|
-
var _useState = useState(document.children),
|
|
35
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
-
slateValue = _useState2[0],
|
|
37
|
-
_setSlateValue = _useState2[1];
|
|
38
|
-
var _useState3 = useState(false),
|
|
39
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
-
isLoading = _useState4[0],
|
|
41
|
-
_setLoading = _useState4[1];
|
|
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];
|
|
50
|
-
|
|
51
|
-
// useMount: init socket connection
|
|
52
|
-
useEffect(function () {
|
|
53
|
-
editor.openConnection();
|
|
54
|
-
return function () {
|
|
55
|
-
editor.closeConnection();
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
-
}, []);
|
|
60
|
-
var updateSlateValue = useCallback(function (value) {
|
|
61
|
-
_setSlateValue(value);
|
|
62
|
-
|
|
63
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
}, []);
|
|
65
|
-
|
|
66
|
-
// The parent component can call the method of this component through ref
|
|
67
|
-
useImperativeHandle(ref, function () {
|
|
68
|
-
return {
|
|
69
|
-
// set value
|
|
70
|
-
setLoading: function setLoading(isLoading) {
|
|
71
|
-
_setLoading(isLoading);
|
|
72
|
-
},
|
|
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
|
-
setSlateValue: function setSlateValue(document) {
|
|
88
|
-
_setSlateValue(document.children);
|
|
89
|
-
},
|
|
90
|
-
// get value
|
|
91
|
-
getSlateValue: function getSlateValue() {
|
|
92
|
-
return deepCopy(_objectSpread(_objectSpread({}, document), {}, {
|
|
93
|
-
children: slateValue
|
|
94
|
-
}));
|
|
95
|
-
},
|
|
96
|
-
// send message
|
|
97
|
-
publishDocument: function publishDocument(originDocUuid, originDocName, callback) {
|
|
98
|
-
editor.publishDocument(originDocUuid, originDocName, callback);
|
|
99
|
-
},
|
|
100
|
-
replaceDocument: function replaceDocument(value, originFileVersion) {
|
|
101
|
-
editor.replaceDocument(value, originFileVersion);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
-
};
|
|
106
|
-
}, [document, editor, slateValue]);
|
|
107
|
-
if (isLoading) {
|
|
108
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
109
|
-
className: "h-100 w-100 d-flex align-items-center justify-content-center"
|
|
110
|
-
}, /*#__PURE__*/React.createElement(CommonLoading, null));
|
|
111
|
-
}
|
|
112
|
-
if (mode === MODE.DIFF_VIEWER) {
|
|
113
|
-
return /*#__PURE__*/React.createElement(DiffViewer, {
|
|
114
|
-
showToolbar: true,
|
|
115
|
-
showOutline: true,
|
|
116
|
-
editor: editor,
|
|
117
|
-
currentContent: currentContent,
|
|
118
|
-
lastContent: diffContent,
|
|
119
|
-
didMountCallback: setDiffChanges
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return /*#__PURE__*/React.createElement(SDocEditor, {
|
|
123
|
-
slateValue: slateValue,
|
|
124
|
-
editor: editor,
|
|
125
|
-
updateSlateValue: updateSlateValue,
|
|
126
|
-
renderElement: renderElement
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
export default Editor;
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
-
import { generateIdMapAndIds, getIdDiffs } from './diff';
|
|
5
|
-
import ObjectUtils from './object-utils';
|
|
6
|
-
import { MODIFY_TYPE, REBASE_TYPE, REBASE_MARK_KEY, REBASE_ORIGIN } from '../constants';
|
|
7
|
-
import { ELEMENT_TYPE } from '../extension/constants';
|
|
8
|
-
import { replaceNodeId } from '../node-id/helpers';
|
|
9
|
-
export var hasConflict = function hasConflict(content) {
|
|
10
|
-
if (!Array.isArray(content) || content.length === 0) return false;
|
|
11
|
-
return content.filter(function (item) {
|
|
12
|
-
return item.rebase_type;
|
|
13
|
-
}).length !== 0;
|
|
14
|
-
};
|
|
15
|
-
var getChanges = function getChanges(masterContent, revisionContent) {
|
|
16
|
-
var _generateIdMapAndIds = generateIdMapAndIds(masterContent.children),
|
|
17
|
-
masterContentMap = _generateIdMapAndIds.map,
|
|
18
|
-
masterIds = _generateIdMapAndIds.ids;
|
|
19
|
-
var _generateIdMapAndIds2 = generateIdMapAndIds(revisionContent.children),
|
|
20
|
-
currentContentMap = _generateIdMapAndIds2.map,
|
|
21
|
-
currentIds = _generateIdMapAndIds2.ids;
|
|
22
|
-
var idDiffs = getIdDiffs(masterIds, currentIds);
|
|
23
|
-
var content = [];
|
|
24
|
-
idDiffs.forEach(function (idDiff) {
|
|
25
|
-
var value = idDiff.value,
|
|
26
|
-
added = idDiff.added,
|
|
27
|
-
removed = idDiff.removed;
|
|
28
|
-
if (added) {
|
|
29
|
-
var addedList = value.map(function (item) {
|
|
30
|
-
return _objectSpread(_objectSpread({}, currentContentMap[item]), {}, _defineProperty({}, REBASE_MARK_KEY.MODIFY_TYPE, MODIFY_TYPE.ADD));
|
|
31
|
-
});
|
|
32
|
-
content.push.apply(content, _toConsumableArray(addedList));
|
|
33
|
-
} else if (removed) {
|
|
34
|
-
var deletedList = value.map(function (item) {
|
|
35
|
-
return _objectSpread(_objectSpread({}, masterContentMap[item]), {}, _defineProperty({}, REBASE_MARK_KEY.MODIFY_TYPE, MODIFY_TYPE.DELETE));
|
|
36
|
-
});
|
|
37
|
-
content.push.apply(content, _toConsumableArray(deletedList));
|
|
38
|
-
} else {
|
|
39
|
-
value.forEach(function (elementId) {
|
|
40
|
-
if (ObjectUtils.isSameObject(masterContentMap[elementId], currentContentMap[elementId])) {
|
|
41
|
-
content.push(currentContentMap[elementId]);
|
|
42
|
-
} else {
|
|
43
|
-
var _objectSpread4;
|
|
44
|
-
var oldElement = masterContentMap[elementId];
|
|
45
|
-
var currentElement = currentContentMap[elementId];
|
|
46
|
-
var newElement = _objectSpread(_objectSpread({}, currentElement), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, REBASE_MARK_KEY.MODIFY_TYPE, MODIFY_TYPE.MODIFY), _defineProperty(_objectSpread4, REBASE_MARK_KEY.OLD_ELEMENT, oldElement), _objectSpread4));
|
|
47
|
-
if (currentElement.type === oldElement.type) {
|
|
48
|
-
var elementType = currentElement.type;
|
|
49
|
-
if ([ELEMENT_TYPE.UNORDERED_LIST, ELEMENT_TYPE.ORDERED_LIST].includes(elementType)) {
|
|
50
|
-
var listContent = getChanges(oldElement, currentElement);
|
|
51
|
-
newElement[REBASE_MARK_KEY.MODIFY_TYPE] = MODIFY_TYPE.CHILDREN_MODIFY;
|
|
52
|
-
newElement['children'] = listContent;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
content.push(newElement);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return content;
|
|
61
|
-
};
|
|
62
|
-
var getMergeElement = function getMergeElement(diffElement, basicElement) {
|
|
63
|
-
var modifyType = diffElement[REBASE_MARK_KEY.MODIFY_TYPE];
|
|
64
|
-
var newElement = _objectSpread({}, diffElement);
|
|
65
|
-
newElement[REBASE_MARK_KEY.MODIFY_TYPE] && delete newElement[REBASE_MARK_KEY.MODIFY_TYPE];
|
|
66
|
-
|
|
67
|
-
// revision does not have this element, master has this element
|
|
68
|
-
if (modifyType === MODIFY_TYPE.DELETE) {
|
|
69
|
-
// basic content does not have this element, indicating that it is newly added by master and needs to be retained, and will not be counted as a conflict.
|
|
70
|
-
if (!basicElement) return [newElement];
|
|
71
|
-
|
|
72
|
-
// basic content has this element, master modified it, indicating that revision deleted it, and the user manually selected the conflict
|
|
73
|
-
if (!ObjectUtils.isSameObject(basicElement, diffElement, [REBASE_MARK_KEY.MODIFY_TYPE])) {
|
|
74
|
-
newElement[REBASE_MARK_KEY.REBASE_TYPE] = REBASE_TYPE.MODIFY_DELETE;
|
|
75
|
-
return [newElement];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// basic content has this element, but master has not modified it. It means that revision has deleted it and the program has deleted it. The conflict will not be counted.
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// revision has this element, master does not have this element
|
|
83
|
-
if (modifyType === MODIFY_TYPE.ADD) {
|
|
84
|
-
// basic content does not have this element, indicating that it is newly added by revision and needs to be retained, and will not be counted as a conflict.
|
|
85
|
-
if (!basicElement) return [newElement];
|
|
86
|
-
|
|
87
|
-
// master deleted it, revision modified it, and the user manually selected the conflict
|
|
88
|
-
if (!ObjectUtils.isSameObject(basicElement, diffElement, [REBASE_MARK_KEY.MODIFY_TYPE])) {
|
|
89
|
-
newElement[REBASE_MARK_KEY.REBASE_TYPE] = REBASE_TYPE.DELETE_MODIFY;
|
|
90
|
-
return [newElement];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// master deleted it, revision did not modify it, the program deleted it, and the conflict is not counted.
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Elements that differ between revision and master
|
|
98
|
-
if (modifyType === MODIFY_TYPE.MODIFY) {
|
|
99
|
-
var _objectSpread7, _objectSpread8;
|
|
100
|
-
var masterElement = _objectSpread({}, diffElement[REBASE_MARK_KEY.OLD_ELEMENT]);
|
|
101
|
-
delete newElement[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
102
|
-
|
|
103
|
-
// revision and master both add a new element, but the content is different. ===》 At present, this situation does not exist, it only exists in the theoretical stage.
|
|
104
|
-
if (!basicElement) {
|
|
105
|
-
var _objectSpread5, _objectSpread6;
|
|
106
|
-
return [_objectSpread(_objectSpread({}, replaceNodeId(masterElement)), {}, (_objectSpread5 = {}, _defineProperty(_objectSpread5, REBASE_MARK_KEY.REBASE_TYPE, REBASE_TYPE.MODIFY_MODIFY), _defineProperty(_objectSpread5, REBASE_MARK_KEY.OLD_ELEMENT, masterElement), _defineProperty(_objectSpread5, REBASE_MARK_KEY.ORIGIN, REBASE_ORIGIN.OTHER), _objectSpread5)), _objectSpread(_objectSpread({}, newElement), {}, (_objectSpread6 = {}, _defineProperty(_objectSpread6, REBASE_MARK_KEY.REBASE_TYPE, REBASE_TYPE.MODIFY_MODIFY), _defineProperty(_objectSpread6, REBASE_MARK_KEY.ORIGIN, REBASE_ORIGIN.MY), _objectSpread6))];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// master is the same as base, indicating that revision has modified the content
|
|
110
|
-
if (ObjectUtils.isSameObject(masterElement, basicElement)) return [newElement];
|
|
111
|
-
|
|
112
|
-
// revision is the same as base, indicating that master has modified the content
|
|
113
|
-
if (ObjectUtils.isSameObject(newElement, basicElement)) return [masterElement];
|
|
114
|
-
|
|
115
|
-
// They are all different. Revision and master were modified at the same time. If there is a conflict, the conflict needs to be resolved manually.
|
|
116
|
-
return [_objectSpread(_objectSpread({}, replaceNodeId(masterElement)), {}, (_objectSpread7 = {}, _defineProperty(_objectSpread7, REBASE_MARK_KEY.REBASE_TYPE, REBASE_TYPE.MODIFY_MODIFY), _defineProperty(_objectSpread7, REBASE_MARK_KEY.OLD_ELEMENT, masterElement), _defineProperty(_objectSpread7, REBASE_MARK_KEY.ORIGIN, REBASE_ORIGIN.OTHER), _objectSpread7)), _objectSpread(_objectSpread({}, newElement), {}, (_objectSpread8 = {}, _defineProperty(_objectSpread8, REBASE_MARK_KEY.REBASE_TYPE, REBASE_TYPE.MODIFY_MODIFY), _defineProperty(_objectSpread8, REBASE_MARK_KEY.ORIGIN, REBASE_ORIGIN.MY), _objectSpread8))];
|
|
117
|
-
}
|
|
118
|
-
if (modifyType === MODIFY_TYPE.CHILDREN_MODIFY) {
|
|
119
|
-
var _masterElement = _objectSpread({}, diffElement[REBASE_MARK_KEY.OLD_ELEMENT]);
|
|
120
|
-
delete newElement[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
121
|
-
|
|
122
|
-
// revision and master both add a new element, but the content is different. ===》 At present, this situation does not exist, it only exists in the theoretical stage.
|
|
123
|
-
if (!basicElement) {
|
|
124
|
-
var _objectSpread9, _objectSpread10;
|
|
125
|
-
return [_objectSpread(_objectSpread({}, replaceNodeId(_masterElement)), {}, (_objectSpread9 = {}, _defineProperty(_objectSpread9, REBASE_MARK_KEY.REBASE_TYPE, REBASE_TYPE.MODIFY_MODIFY), _defineProperty(_objectSpread9, REBASE_MARK_KEY.OLD_ELEMENT, _masterElement), _defineProperty(_objectSpread9, REBASE_MARK_KEY.ORIGIN, REBASE_ORIGIN.OTHER), _objectSpread9)), _objectSpread(_objectSpread({}, newElement), {}, (_objectSpread10 = {}, _defineProperty(_objectSpread10, REBASE_MARK_KEY.REBASE_TYPE, REBASE_TYPE.MODIFY_MODIFY), _defineProperty(_objectSpread10, REBASE_MARK_KEY.ORIGIN, REBASE_ORIGIN.MY), _objectSpread10))];
|
|
126
|
-
}
|
|
127
|
-
if (ObjectUtils.isSameObject(_masterElement, basicElement)) return [newElement];
|
|
128
|
-
if (ObjectUtils.isSameObject(newElement, basicElement)) return [_masterElement];
|
|
129
|
-
if (ObjectUtils.isSameObject(_masterElement, newElement, ['type'])) {
|
|
130
|
-
if (ObjectUtils.isSameObject(_masterElement, basicElement, ['type'])) return [newElement];
|
|
131
|
-
if (ObjectUtils.isSameObject(newElement, basicElement, ['type'])) return [_masterElement];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// The content of the subnode has changed and needs to be solved manually.
|
|
135
|
-
var _getMergeContent = getMergeContent(basicElement, diffElement.children),
|
|
136
|
-
childrenContent = _getMergeContent.content;
|
|
137
|
-
return [_objectSpread(_objectSpread({}, newElement), {}, _defineProperty({
|
|
138
|
-
children: childrenContent
|
|
139
|
-
}, REBASE_MARK_KEY.REBASE_TYPE, REBASE_TYPE.CHILDREN_MODIFY))];
|
|
140
|
-
}
|
|
141
|
-
newElement[REBASE_MARK_KEY.OLD_ELEMENT] && delete newElement[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
142
|
-
return [newElement];
|
|
143
|
-
};
|
|
144
|
-
var getMergeContent = function getMergeContent(basicContent, diffChanges) {
|
|
145
|
-
var _generateIdMapAndIds3 = generateIdMapAndIds(diffChanges),
|
|
146
|
-
diffChangesContentMap = _generateIdMapAndIds3.map,
|
|
147
|
-
diffChangesContentIds = _generateIdMapAndIds3.ids;
|
|
148
|
-
var _generateIdMapAndIds4 = generateIdMapAndIds(basicContent.children),
|
|
149
|
-
baseContentMap = _generateIdMapAndIds4.map;
|
|
150
|
-
var content = [];
|
|
151
|
-
diffChangesContentIds.forEach(function (elementId) {
|
|
152
|
-
var diffElement = diffChangesContentMap[elementId];
|
|
153
|
-
var basicElement = baseContentMap[elementId];
|
|
154
|
-
var mergeElements = getMergeElement(diffElement, basicElement);
|
|
155
|
-
content.push.apply(content, _toConsumableArray(mergeElements));
|
|
156
|
-
});
|
|
157
|
-
var canMerge = !hasConflict(content);
|
|
158
|
-
return {
|
|
159
|
-
content: content,
|
|
160
|
-
canMerge: canMerge
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
export var getRebase = function getRebase(masterContent, basicContent, revisionContent) {
|
|
164
|
-
// master no changes, merged directly
|
|
165
|
-
if (masterContent.version === basicContent.version) {
|
|
166
|
-
return {
|
|
167
|
-
canMerge: true,
|
|
168
|
-
isNeedReplaceMaster: true,
|
|
169
|
-
value: revisionContent
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// The revision content has not changed
|
|
174
|
-
if (basicContent.version === revisionContent.version) {
|
|
175
|
-
return {
|
|
176
|
-
canMerge: true,
|
|
177
|
-
isNeedReplaceMaster: false,
|
|
178
|
-
value: masterContent
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
var diffChanges = getChanges(masterContent, revisionContent);
|
|
182
|
-
var _getMergeContent2 = getMergeContent(basicContent, diffChanges),
|
|
183
|
-
canMerge = _getMergeContent2.canMerge,
|
|
184
|
-
content = _getMergeContent2.content;
|
|
185
|
-
return {
|
|
186
|
-
canMerge: canMerge,
|
|
187
|
-
isNeedReplaceMaster: true,
|
|
188
|
-
value: _objectSpread(_objectSpread({}, revisionContent), {}, {
|
|
189
|
-
children: content,
|
|
190
|
-
version: Math.max(masterContent.version, revisionContent.version) + 1
|
|
191
|
-
})
|
|
192
|
-
};
|
|
193
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
import { TIP_TYPE, TIP_TITLE } from '../../constants';
|
|
6
|
-
import TipContent from './tip-content';
|
|
7
|
-
var TipDialog = function TipDialog(_ref) {
|
|
8
|
-
var className = _ref.className,
|
|
9
|
-
tipType = _ref.tipType,
|
|
10
|
-
toggle = _ref.toggle,
|
|
11
|
-
submit = _ref.submit;
|
|
12
|
-
var _useTranslation = useTranslation(),
|
|
13
|
-
t = _useTranslation.t;
|
|
14
|
-
var closeDialog = useCallback(function () {
|
|
15
|
-
toggle && toggle(false);
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
-
}, [tipType]);
|
|
19
|
-
var confirmTip = useCallback(function () {
|
|
20
|
-
submit && submit();
|
|
21
|
-
|
|
22
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
-
}, []);
|
|
24
|
-
return /*#__PURE__*/React.createElement(Modal, {
|
|
25
|
-
isOpen: true,
|
|
26
|
-
autoFocus: false,
|
|
27
|
-
zIndex: 1071,
|
|
28
|
-
returnFocusAfterClose: false,
|
|
29
|
-
toggle: closeDialog,
|
|
30
|
-
className: classnames('sdoc-tip-dialog', className),
|
|
31
|
-
contentClassName: "sdoc-tip-modal"
|
|
32
|
-
}, /*#__PURE__*/React.createElement(ModalHeader, {
|
|
33
|
-
toggle: [TIP_TYPE.HAS_BEEN_REPLACED, TIP_TYPE.HAS_BEEN_PUBLISHED].includes(tipType) ? undefined : closeDialog
|
|
34
|
-
}, t(TIP_TITLE[tipType])), /*#__PURE__*/React.createElement(ModalBody, {
|
|
35
|
-
className: "sdoc-tip-body"
|
|
36
|
-
}, /*#__PURE__*/React.createElement(TipContent, {
|
|
37
|
-
tipType: tipType
|
|
38
|
-
})), ![TIP_TYPE.HAS_BEEN_REPLACED, TIP_TYPE.HAS_BEEN_PUBLISHED].includes(tipType) && /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
39
|
-
color: "secondary",
|
|
40
|
-
className: "mr-2",
|
|
41
|
-
onClick: closeDialog
|
|
42
|
-
}, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
|
|
43
|
-
color: "primary",
|
|
44
|
-
className: "highlight-bg-color",
|
|
45
|
-
onClick: confirmTip
|
|
46
|
-
}, t('Confirm'))));
|
|
47
|
-
};
|
|
48
|
-
export default TipDialog;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { TIP_TYPE, TIP_CONTENT } from '../../constants';
|
|
6
|
-
import context from '../../context';
|
|
7
|
-
var TipContent = function TipContent(_ref) {
|
|
8
|
-
var tipType = _ref.tipType;
|
|
9
|
-
var _useState = useState(3),
|
|
10
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
11
|
-
time = _useState2[0],
|
|
12
|
-
setTime = _useState2[1];
|
|
13
|
-
useEffect(function () {
|
|
14
|
-
if (tipType === TIP_TYPE.HAS_BEEN_PUBLISHED) {
|
|
15
|
-
var _time = 3;
|
|
16
|
-
var timer = setInterval(function () {
|
|
17
|
-
_time--;
|
|
18
|
-
setTime(_time);
|
|
19
|
-
if (_time === 0) {
|
|
20
|
-
clearInterval(timer);
|
|
21
|
-
timer = null;
|
|
22
|
-
}
|
|
23
|
-
}, 1000);
|
|
24
|
-
return function () {
|
|
25
|
-
timer && clearInterval(timer);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}, [tipType]);
|
|
29
|
-
useEffect(function () {
|
|
30
|
-
if (time === 0) {
|
|
31
|
-
var originFileURL = context.getSetting('originFileURL');
|
|
32
|
-
window.location.href = originFileURL;
|
|
33
|
-
}
|
|
34
|
-
}, [time]);
|
|
35
|
-
var _useTranslation = useTranslation(),
|
|
36
|
-
t = _useTranslation.t;
|
|
37
|
-
if (tipType === TIP_TYPE.HAS_BEEN_PUBLISHED) {
|
|
38
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, t(TIP_CONTENT[tipType], {
|
|
39
|
-
time: time
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, t(TIP_CONTENT[tipType]));
|
|
43
|
-
};
|
|
44
|
-
TipContent.propTypes = {
|
|
45
|
-
tipType: PropTypes.string
|
|
46
|
-
};
|
|
47
|
-
export default TipContent;
|