@seafile/sdoc-editor 0.1.28-beta6 → 0.1.28
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/extension/constants/index.js +31 -11
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +2 -2
- package/dist/config.js +16 -0
- package/package.json +1 -1
- package/dist/assets/css/diff-viewer.css +0 -19
- package/dist/basic-sdk/extension/constants/element-type.js +0 -29
- package/dist/basic-sdk/utils/diff.js +0 -185
- package/dist/basic-sdk/utils/object-utils.js +0 -57
- package/dist/pages/diff-viewer/diff-viewer.js +0 -115
- package/dist/pages/diff-viewer/history-version-viewer.js +0 -10
- package/dist/pages/diff-viewer/index.js +0 -32
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
var _MENUS_CONFIG_MAP, _HEADER_TITLE_MAP;
|
|
3
3
|
// extension plugin
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export var BLOCKQUOTE = 'blockquote';
|
|
5
|
+
export var BOLD = 'bold';
|
|
6
|
+
export var ITALIC = 'italic';
|
|
7
|
+
export var HEADER = 'header';
|
|
8
|
+
export var HEADER1 = 'header1';
|
|
9
|
+
export var HEADER2 = 'header2';
|
|
10
|
+
export var HEADER3 = 'header3';
|
|
11
|
+
export var HEADER4 = 'header4';
|
|
12
|
+
export var HEADER5 = 'header5';
|
|
13
|
+
export var HEADER6 = 'header6';
|
|
14
|
+
export var ORDERED_LIST = 'ordered_list';
|
|
15
|
+
export var UNORDERED_LIST = 'unordered_list'; // unordered_list can not work
|
|
16
|
+
export var LIST_ITEM = 'list-item';
|
|
17
|
+
export var LIST_LIC = 'list-lic'; // placeholder
|
|
18
|
+
export var CHECK_LIST = 'check-list';
|
|
19
|
+
export var CHECK_LIST_ITEM = 'check-list-item';
|
|
20
|
+
export var PARAGRAPH = 'paragraph';
|
|
21
|
+
export var LINK = 'link';
|
|
22
|
+
export var HTML = 'html';
|
|
23
|
+
export var CODE_BLOCK = 'code-block';
|
|
24
|
+
export var CODE_LINE = 'code-line';
|
|
25
|
+
export var IMAGE = 'image';
|
|
26
|
+
export var TABLE = 'table';
|
|
27
|
+
export var TABLE_CELL = 'table-cell';
|
|
28
|
+
export var TABLE_ROW = 'table-row';
|
|
29
|
+
export var FORMULA = 'formula';
|
|
30
|
+
export var COLUMN = 'column';
|
|
31
|
+
export var TEXTSTYLE = 'text-style';
|
|
32
|
+
export var BOLD_ITALIC = 'bold-italic';
|
|
6
33
|
|
|
7
34
|
// history
|
|
8
35
|
export var UNDO = 'undo';
|
|
@@ -37,7 +64,7 @@ export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CO
|
|
|
37
64
|
id: "sdoc_".concat(IMAGE),
|
|
38
65
|
iconClass: 'iconfont icon-image',
|
|
39
66
|
text: 'insert_image'
|
|
40
|
-
}), _defineProperty(_MENUS_CONFIG_MAP,
|
|
67
|
+
}), _defineProperty(_MENUS_CONFIG_MAP, TEXTSTYLE, [{
|
|
41
68
|
id: ITALIC,
|
|
42
69
|
iconClass: 'iconfont icon-italic',
|
|
43
70
|
text: 'italic',
|
|
@@ -58,11 +85,4 @@ export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CO
|
|
|
58
85
|
text: 'redo',
|
|
59
86
|
type: 'redo'
|
|
60
87
|
}), _MENUS_CONFIG_MAP);
|
|
61
|
-
export var HEADER_TITLE_MAP = (_HEADER_TITLE_MAP = {}, _defineProperty(_HEADER_TITLE_MAP, HEADER1, 'header_one'), _defineProperty(_HEADER_TITLE_MAP, HEADER2, 'header_two'), _defineProperty(_HEADER_TITLE_MAP, HEADER3, 'header_three'), _defineProperty(_HEADER_TITLE_MAP, HEADER4, 'header_four'), _defineProperty(_HEADER_TITLE_MAP, HEADER5, 'header_five'), _defineProperty(_HEADER_TITLE_MAP, HEADER6, 'header_six'), _defineProperty(_HEADER_TITLE_MAP, PARAGRAPH, 'paragraph'), _HEADER_TITLE_MAP);
|
|
62
|
-
export var DIFF_TYPE = {
|
|
63
|
-
ADD: 'add',
|
|
64
|
-
DELETE: 'delete',
|
|
65
|
-
MODIFY: 'modify',
|
|
66
|
-
COMMON: 'common'
|
|
67
|
-
};
|
|
68
|
-
export { BLOCKQUOTE, BOLD, ITALIC, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST, CHECK_LIST_ITEM, PARAGRAPH, LINK, HTML, CODE_BLOCK, CODE_LINE, IMAGE, TABLE, TABLE_CELL, TABLE_ROW, FORMULA, COLUMN, TEXT_STYLE, BOLD_ITALIC, ELEMENT_TYPE };
|
|
88
|
+
export var HEADER_TITLE_MAP = (_HEADER_TITLE_MAP = {}, _defineProperty(_HEADER_TITLE_MAP, HEADER1, 'header_one'), _defineProperty(_HEADER_TITLE_MAP, HEADER2, 'header_two'), _defineProperty(_HEADER_TITLE_MAP, HEADER3, 'header_three'), _defineProperty(_HEADER_TITLE_MAP, HEADER4, 'header_four'), _defineProperty(_HEADER_TITLE_MAP, HEADER5, 'header_five'), _defineProperty(_HEADER_TITLE_MAP, HEADER6, 'header_six'), _defineProperty(_HEADER_TITLE_MAP, PARAGRAPH, 'paragraph'), _HEADER_TITLE_MAP);
|
|
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import {
|
|
7
|
+
import { TEXTSTYLE, MENUS_CONFIG_MAP } from '../../../constants';
|
|
8
8
|
import { focusEditor } from '../../../core';
|
|
9
9
|
import { MenuItem } from '../../../menu';
|
|
10
10
|
import { getValue, isMenuDisabled, addMark, removeMark } from '../helpers';
|
|
@@ -68,7 +68,7 @@ var TextStyleMenuList = /*#__PURE__*/function (_React$Component) {
|
|
|
68
68
|
value: function render() {
|
|
69
69
|
var textStyleMenuList = this.getTextStyleMenuList();
|
|
70
70
|
return /*#__PURE__*/React.createElement(React.Fragment, null, textStyleMenuList.map(function (menuItem, index) {
|
|
71
|
-
var menuItemConfig = MENUS_CONFIG_MAP[
|
|
71
|
+
var menuItemConfig = MENUS_CONFIG_MAP[TEXTSTYLE][index];
|
|
72
72
|
var menuItemProps = _objectSpread(_objectSpread({}, menuItem), menuItemConfig);
|
|
73
73
|
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({
|
|
74
74
|
key: index
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var serverConfig = {
|
|
2
|
+
//serviceUrl: "http://127.0.0.1:8000",
|
|
3
|
+
serviceUrl: "http://192.168.1.100:8000",
|
|
4
|
+
username: "lj@11.com",
|
|
5
|
+
password: "11",
|
|
6
|
+
repoID: "79d1fa93-4b5f-4d6c-8fb5-ad3958e1fa47",
|
|
7
|
+
userInfo: {
|
|
8
|
+
username: 'lj@11.com',
|
|
9
|
+
name: 'lj-',
|
|
10
|
+
contact_email: 'lj@11.com'
|
|
11
|
+
},
|
|
12
|
+
filePath: '/xxx.md',
|
|
13
|
+
fileName: 'xxx.md',
|
|
14
|
+
dirPath: '/'
|
|
15
|
+
};
|
|
16
|
+
export { serverConfig };
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
.sdoc-diff {
|
|
2
|
-
padding: 0 5px;
|
|
3
|
-
margin: 0 -5px;
|
|
4
|
-
overflow: hidden;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.sdoc-diff-added {
|
|
8
|
-
background-color: #e6ffed;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.sdoc-diff-removed {
|
|
12
|
-
background-color: #ffeef0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.sdoc-diff-modify {
|
|
16
|
-
padding-left: 2px;
|
|
17
|
-
margin-left: -5px;
|
|
18
|
-
border-left: 3px solid #f9c513;
|
|
19
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export var BLOCKQUOTE = 'blockquote';
|
|
2
|
-
export var BOLD = 'bold';
|
|
3
|
-
export var ITALIC = 'italic';
|
|
4
|
-
export var HEADER = 'header';
|
|
5
|
-
export var HEADER1 = 'header1';
|
|
6
|
-
export var HEADER2 = 'header2';
|
|
7
|
-
export var HEADER3 = 'header3';
|
|
8
|
-
export var HEADER4 = 'header4';
|
|
9
|
-
export var HEADER5 = 'header5';
|
|
10
|
-
export var HEADER6 = 'header6';
|
|
11
|
-
export var ORDERED_LIST = 'ordered_list';
|
|
12
|
-
export var UNORDERED_LIST = 'unordered_list'; // unordered_list can not work
|
|
13
|
-
export var LIST_ITEM = 'list-item';
|
|
14
|
-
export var LIST_LIC = 'list-lic'; // placeholder
|
|
15
|
-
export var CHECK_LIST = 'check-list';
|
|
16
|
-
export var CHECK_LIST_ITEM = 'check-list-item';
|
|
17
|
-
export var PARAGRAPH = 'paragraph';
|
|
18
|
-
export var LINK = 'link';
|
|
19
|
-
export var HTML = 'html';
|
|
20
|
-
export var CODE_BLOCK = 'code-block';
|
|
21
|
-
export var CODE_LINE = 'code-line';
|
|
22
|
-
export var IMAGE = 'image';
|
|
23
|
-
export var TABLE = 'table';
|
|
24
|
-
export var TABLE_CELL = 'table-cell';
|
|
25
|
-
export var TABLE_ROW = 'table-row';
|
|
26
|
-
export var FORMULA = 'formula';
|
|
27
|
-
export var COLUMN = 'column';
|
|
28
|
-
export var TEXT_STYLE = 'text-style';
|
|
29
|
-
export var BOLD_ITALIC = 'bold-italic';
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import { DIFF_TYPE, ELEMENT_TYPE } from '../../basic-sdk/extension/constants';
|
|
4
|
-
import ObjectUtils from './object-utils';
|
|
5
|
-
var getElementIndexInDiffDocument = function getElementIndexInDiffDocument(diffValue, element) {
|
|
6
|
-
return diffValue.findIndex(function (item) {
|
|
7
|
-
return item.id === element.id;
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var getNearestElementIndex = function getNearestElementIndex(diff, oldDocument, elementId) {
|
|
11
|
-
var diffValue = diff.value;
|
|
12
|
-
var elementInDiffDocumentIdx = getElementIndexInDiffDocument(diffValue, elementId);
|
|
13
|
-
if (elementInDiffDocumentIdx > -1) return elementInDiffDocumentIdx + 1;
|
|
14
|
-
var oldElementCount = oldDocument.length;
|
|
15
|
-
var elementInOldDocumentIndex = oldDocument.findIndex(function (item) {
|
|
16
|
-
return item.id === elementId;
|
|
17
|
-
});
|
|
18
|
-
var leftIndex = elementInOldDocumentIndex - 1;
|
|
19
|
-
leftIndex = leftIndex === -1 ? 0 : leftIndex;
|
|
20
|
-
var rightIndex = elementInOldDocumentIndex + 1;
|
|
21
|
-
rightIndex = rightIndex === oldElementCount - 1 ? oldElementCount - 1 : rightIndex;
|
|
22
|
-
while (elementInDiffDocumentIdx === -1 && leftIndex > -2 && rightIndex < oldElementCount + 1) {
|
|
23
|
-
if (leftIndex > -1) {
|
|
24
|
-
var oldLeftElement = oldDocument[leftIndex];
|
|
25
|
-
elementInDiffDocumentIdx = getElementIndexInDiffDocument(diffValue, oldLeftElement);
|
|
26
|
-
if (elementInDiffDocumentIdx > -1) {
|
|
27
|
-
return elementInDiffDocumentIdx + 1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
if (rightIndex < oldElementCount) {
|
|
31
|
-
var oldLastElement = oldDocument[rightIndex];
|
|
32
|
-
elementInDiffDocumentIdx = getElementIndexInDiffDocument(diffValue, oldLastElement);
|
|
33
|
-
if (elementInDiffDocumentIdx > -1) {
|
|
34
|
-
return elementInDiffDocumentIdx;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
leftIndex--;
|
|
38
|
-
rightIndex++;
|
|
39
|
-
if (leftIndex === -2 && rightIndex < oldElementCount) {
|
|
40
|
-
leftIndex = -1;
|
|
41
|
-
}
|
|
42
|
-
if (rightIndex === oldElementCount && leftIndex > -1) {
|
|
43
|
-
rightIndex = oldElementCount;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return diffValue.length - 1;
|
|
47
|
-
};
|
|
48
|
-
var updateDiffValue = function updateDiffValue(diff, element, oldElement) {
|
|
49
|
-
if (!diff || !element || !oldElement) return;
|
|
50
|
-
if (ObjectUtils.isSameObject(element, oldElement)) {
|
|
51
|
-
diff.value.push(_objectSpread(_objectSpread({}, element), {}, {
|
|
52
|
-
diff_type: DIFF_TYPE.COMMON
|
|
53
|
-
}));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
var currentElementType = element.type;
|
|
57
|
-
var oldElementType = oldElement.type;
|
|
58
|
-
if (currentElementType !== oldElementType) {
|
|
59
|
-
diff.changes.push(oldElement.id);
|
|
60
|
-
diff.value.push(_objectSpread(_objectSpread({}, oldElement), {}, {
|
|
61
|
-
diff_type: DIFF_TYPE.DELETE
|
|
62
|
-
}));
|
|
63
|
-
diff.value.push(_objectSpread(_objectSpread({}, element), {}, {
|
|
64
|
-
diff_type: DIFF_TYPE.ADD
|
|
65
|
-
}));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
switch (currentElementType) {
|
|
69
|
-
case ELEMENT_TYPE.PARAGRAPH:
|
|
70
|
-
case ELEMENT_TYPE.HEADER1:
|
|
71
|
-
case ELEMENT_TYPE.HEADER2:
|
|
72
|
-
case ELEMENT_TYPE.HEADER3:
|
|
73
|
-
case ELEMENT_TYPE.HEADER4:
|
|
74
|
-
case ELEMENT_TYPE.HEADER5:
|
|
75
|
-
case ELEMENT_TYPE.HEADER6:
|
|
76
|
-
case ELEMENT_TYPE.BLOCKQUOTE:
|
|
77
|
-
case ELEMENT_TYPE.LINK:
|
|
78
|
-
case ELEMENT_TYPE.CHECK_LIST_ITEM:
|
|
79
|
-
case ELEMENT_TYPE.CODE_BLOCK:
|
|
80
|
-
case ELEMENT_TYPE.IMAGE:
|
|
81
|
-
{
|
|
82
|
-
diff.changes.push(oldElement.id);
|
|
83
|
-
diff.value.push(_objectSpread(_objectSpread({}, oldElement), {}, {
|
|
84
|
-
diff_type: DIFF_TYPE.DELETE
|
|
85
|
-
}));
|
|
86
|
-
diff.value.push(_objectSpread(_objectSpread({}, element), {}, {
|
|
87
|
-
diff_type: DIFF_TYPE.ADD
|
|
88
|
-
}));
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case ELEMENT_TYPE.ORDERED_LIST:
|
|
92
|
-
case ELEMENT_TYPE.UNORDERED_LIST:
|
|
93
|
-
case ELEMENT_TYPE.LIST_ITEM:
|
|
94
|
-
case ELEMENT_TYPE.LIST_LIC:
|
|
95
|
-
{
|
|
96
|
-
var _diff$changes;
|
|
97
|
-
var _getElementDiffValue = getElementDiffValue(element.children, oldElement.children),
|
|
98
|
-
diffValue = _getElementDiffValue.value,
|
|
99
|
-
diffChanges = _getElementDiffValue.changes;
|
|
100
|
-
(_diff$changes = diff.changes).push.apply(_diff$changes, _toConsumableArray(diffChanges));
|
|
101
|
-
diff.value.push(_objectSpread(_objectSpread({}, element), {}, {
|
|
102
|
-
children: diffValue,
|
|
103
|
-
diff_type: DIFF_TYPE.MODIFY
|
|
104
|
-
}));
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
default:
|
|
108
|
-
{
|
|
109
|
-
diff.changes.push(oldElement.id);
|
|
110
|
-
diff.value.push(_objectSpread(_objectSpread({}, oldElement), {}, {
|
|
111
|
-
diff_type: DIFF_TYPE.DELETE
|
|
112
|
-
}));
|
|
113
|
-
diff.value.push(_objectSpread(_objectSpread({}, element), {}, {
|
|
114
|
-
diff_type: DIFF_TYPE.ADD
|
|
115
|
-
}));
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* params:
|
|
123
|
-
* currentValue: current version document content
|
|
124
|
-
* oldValue: last version document content
|
|
125
|
-
* return { value: [], change: [] }
|
|
126
|
-
*/
|
|
127
|
-
var getElementDiffValue = function getElementDiffValue(currentContent, oldContent) {
|
|
128
|
-
// init
|
|
129
|
-
var diff = {
|
|
130
|
-
value: [],
|
|
131
|
-
changes: []
|
|
132
|
-
};
|
|
133
|
-
var currentContentMap = {};
|
|
134
|
-
var oldContentMap = {};
|
|
135
|
-
currentContent.forEach(function (element) {
|
|
136
|
-
currentContentMap[element.id] = element;
|
|
137
|
-
});
|
|
138
|
-
oldContent.forEach(function (element) {
|
|
139
|
-
oldContentMap[element.id] = element;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// generator diff elements
|
|
143
|
-
for (var i = 0; i < currentContent.length; i++) {
|
|
144
|
-
var element = currentContent[i];
|
|
145
|
-
var isAdded = !oldContentMap[element.id]; // added
|
|
146
|
-
if (isAdded) {
|
|
147
|
-
diff.changes.push(element.id);
|
|
148
|
-
diff.value.push(_objectSpread(_objectSpread({}, element), {}, {
|
|
149
|
-
diff_type: DIFF_TYPE.ADD
|
|
150
|
-
}));
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
updateDiffValue(diff, element, oldContentMap[element.id]);
|
|
154
|
-
}
|
|
155
|
-
oldContent.forEach(function (oldElement) {
|
|
156
|
-
var oldElementId = oldElement.id;
|
|
157
|
-
if (!currentContentMap[oldElementId]) {
|
|
158
|
-
// deleted
|
|
159
|
-
diff.changes.push(oldElementId);
|
|
160
|
-
var elementIndex = getNearestElementIndex(diff, oldContent, oldElementId);
|
|
161
|
-
diff.value.splice(elementIndex, 0, _objectSpread(_objectSpread({}, oldElement), {}, {
|
|
162
|
-
diff_type: DIFF_TYPE.DELETE
|
|
163
|
-
}));
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
return diff;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* params:
|
|
171
|
-
* currentValue: current version document
|
|
172
|
-
* oldValue: last version document
|
|
173
|
-
* return { value: [], change: [] }
|
|
174
|
-
*/
|
|
175
|
-
export var getDiff = function getDiff(currentValue, oldValue) {
|
|
176
|
-
var currentVersion = currentValue.version,
|
|
177
|
-
currentContent = currentValue.children;
|
|
178
|
-
var oldVersion = oldValue.version,
|
|
179
|
-
oldContent = oldValue.children;
|
|
180
|
-
if (currentVersion === oldVersion) return {
|
|
181
|
-
value: currentContent,
|
|
182
|
-
changes: []
|
|
183
|
-
};
|
|
184
|
-
return getElementDiffValue(currentContent, oldContent);
|
|
185
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
var ObjectUtils = /*#__PURE__*/function () {
|
|
5
|
-
function ObjectUtils() {
|
|
6
|
-
_classCallCheck(this, ObjectUtils);
|
|
7
|
-
}
|
|
8
|
-
_createClass(ObjectUtils, null, [{
|
|
9
|
-
key: "getDataType",
|
|
10
|
-
value: function getDataType(data) {
|
|
11
|
-
var type = typeof data;
|
|
12
|
-
if (type !== 'object') {
|
|
13
|
-
return type;
|
|
14
|
-
}
|
|
15
|
-
return Object.prototype.toString.call(data).replace(/^\[object (\S+)\]$/, '$1');
|
|
16
|
-
}
|
|
17
|
-
}, {
|
|
18
|
-
key: "iterable",
|
|
19
|
-
value: function iterable(data) {
|
|
20
|
-
return ['Object', 'Array'].includes(this.getDataType(data));
|
|
21
|
-
}
|
|
22
|
-
}, {
|
|
23
|
-
key: "isObjectChanged",
|
|
24
|
-
value: function isObjectChanged(source, comparison, notIncludeKeys) {
|
|
25
|
-
var _this = this;
|
|
26
|
-
if (!this.iterable(source)) {
|
|
27
|
-
throw new Error("source should be a Object or Array , but got ".concat(this.getDataType(source)));
|
|
28
|
-
}
|
|
29
|
-
if (this.getDataType(source) !== this.getDataType(comparison)) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
var sourceKeys = Object.keys(source);
|
|
33
|
-
var comparisonKeys = Object.keys(_objectSpread(_objectSpread({}, source), comparison)).filter(function (key) {
|
|
34
|
-
return !notIncludeKeys.includes(key);
|
|
35
|
-
});
|
|
36
|
-
if (sourceKeys.length !== comparisonKeys.length) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return comparisonKeys.some(function (key) {
|
|
40
|
-
if (_this.iterable(source[key])) {
|
|
41
|
-
return _this.isObjectChanged(source[key], comparison[key], notIncludeKeys);
|
|
42
|
-
} else {
|
|
43
|
-
return source[key] !== comparison[key];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "isSameObject",
|
|
49
|
-
value: function isSameObject(source, comparison) {
|
|
50
|
-
var notIncludeKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
51
|
-
if (!source || !comparison) return false;
|
|
52
|
-
return !this.isObjectChanged(source, comparison, notIncludeKeys);
|
|
53
|
-
}
|
|
54
|
-
}]);
|
|
55
|
-
return ObjectUtils;
|
|
56
|
-
}();
|
|
57
|
-
export default ObjectUtils;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
-
import React, { Component } from 'react';
|
|
7
|
-
import { Editable, Slate } from '@seafile/slate-react';
|
|
8
|
-
import editor, { renderLeaf, renderElement } from '../../basic-sdk/extension';
|
|
9
|
-
import withNodeId from '../../basic-sdk/node-id';
|
|
10
|
-
import { getDiff } from '../../basic-sdk/utils/diff';
|
|
11
|
-
import { DIFF_TYPE, ELEMENT_TYPE } from '../../basic-sdk/extension/constants';
|
|
12
|
-
import '../../assets/css/diff-viewer.css';
|
|
13
|
-
var DiffViewer = /*#__PURE__*/function (_Component) {
|
|
14
|
-
_inherits(DiffViewer, _Component);
|
|
15
|
-
var _super = _createSuper(DiffViewer);
|
|
16
|
-
function DiffViewer(_props) {
|
|
17
|
-
var _this;
|
|
18
|
-
_classCallCheck(this, DiffViewer);
|
|
19
|
-
_this = _super.call(this, _props);
|
|
20
|
-
_this.renderLeaf = function (props) {
|
|
21
|
-
return renderLeaf(props, _this.editor);
|
|
22
|
-
};
|
|
23
|
-
_this.renderElement = function (props) {
|
|
24
|
-
var element = props.element;
|
|
25
|
-
var diff_type = element.diff_type,
|
|
26
|
-
type = element.type;
|
|
27
|
-
if (diff_type === DIFF_TYPE.ADD) {
|
|
28
|
-
if (type === ELEMENT_TYPE.LIST_ITEM) {
|
|
29
|
-
return renderElement(_objectSpread(_objectSpread({}, props), {}, {
|
|
30
|
-
attributes: _objectSpread(_objectSpread({}, props.attributes), {}, {
|
|
31
|
-
className: 'sdoc-diff-added'
|
|
32
|
-
})
|
|
33
|
-
}), _this.editor);
|
|
34
|
-
}
|
|
35
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
-
className: "sdoc-diff sdoc-diff-added"
|
|
37
|
-
}, renderElement(_objectSpread(_objectSpread({}, props), {}, {
|
|
38
|
-
attributes: _objectSpread(_objectSpread({}, props.attributes), {}, {
|
|
39
|
-
className: 'sdoc-diff-added'
|
|
40
|
-
})
|
|
41
|
-
}), _this.editor));
|
|
42
|
-
}
|
|
43
|
-
if (diff_type === DIFF_TYPE.DELETE) {
|
|
44
|
-
if (type === ELEMENT_TYPE.LIST_ITEM) {
|
|
45
|
-
return renderElement(_objectSpread(_objectSpread({}, props), {}, {
|
|
46
|
-
attributes: _objectSpread(_objectSpread({}, props.attributes), {}, {
|
|
47
|
-
className: 'sdoc-diff-removed'
|
|
48
|
-
})
|
|
49
|
-
}), _this.editor);
|
|
50
|
-
}
|
|
51
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
-
className: "sdoc-diff sdoc-diff-removed"
|
|
53
|
-
}, renderElement(_objectSpread(_objectSpread({}, props), {}, {
|
|
54
|
-
attributes: _objectSpread(_objectSpread({}, props.attributes), {}, {
|
|
55
|
-
className: 'sdoc-diff-removed'
|
|
56
|
-
})
|
|
57
|
-
}), _this.editor));
|
|
58
|
-
}
|
|
59
|
-
if (diff_type === DIFF_TYPE.MODIFY) {
|
|
60
|
-
if (type === ELEMENT_TYPE.ORDERED_LIST || type === ELEMENT_TYPE.UNORDERED_LIST) {
|
|
61
|
-
return renderElement(_objectSpread(_objectSpread({}, props), {}, {
|
|
62
|
-
attributes: _objectSpread(_objectSpread({}, props.attributes), {}, {
|
|
63
|
-
className: 'sdoc-diff-modify'
|
|
64
|
-
})
|
|
65
|
-
}), _this.editor);
|
|
66
|
-
}
|
|
67
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
68
|
-
className: "sdoc-diff-modify"
|
|
69
|
-
}, renderElement(_objectSpread(_objectSpread({}, props), {}, {
|
|
70
|
-
attributes: _objectSpread(_objectSpread({}, props.attributes), {}, {
|
|
71
|
-
className: 'sdoc-diff-modify'
|
|
72
|
-
})
|
|
73
|
-
}), _this.editor));
|
|
74
|
-
}
|
|
75
|
-
return renderElement(props, _this.editor);
|
|
76
|
-
};
|
|
77
|
-
var currentContent = _props.currentContent,
|
|
78
|
-
lastContent = _props.lastContent;
|
|
79
|
-
_this.diff = getDiff(currentContent, lastContent);
|
|
80
|
-
_this.editor = withNodeId(editor);
|
|
81
|
-
return _this;
|
|
82
|
-
}
|
|
83
|
-
_createClass(DiffViewer, [{
|
|
84
|
-
key: "componentDidMount",
|
|
85
|
-
value: function componentDidMount() {
|
|
86
|
-
this.props.didMountCallback && this.props.didMountCallback(this.diff);
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "render",
|
|
90
|
-
value: function render() {
|
|
91
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
className: "sdoc-editor-container"
|
|
93
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
94
|
-
className: "sdoc-editor-content"
|
|
95
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
96
|
-
className: "flex-fill o-auto"
|
|
97
|
-
}, /*#__PURE__*/React.createElement(Slate, {
|
|
98
|
-
editor: this.editor,
|
|
99
|
-
value: this.diff.value,
|
|
100
|
-
onChange: function onChange() {}
|
|
101
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
className: "article mx-auto"
|
|
103
|
-
}, /*#__PURE__*/React.createElement(Editable, {
|
|
104
|
-
readOnly: true,
|
|
105
|
-
placeholder: "",
|
|
106
|
-
renderElement: this.renderElement,
|
|
107
|
-
renderLeaf: this.renderLeaf,
|
|
108
|
-
onDOMBeforeInput: function onDOMBeforeInput() {},
|
|
109
|
-
onKeyDown: function onKeyDown() {}
|
|
110
|
-
}))))));
|
|
111
|
-
}
|
|
112
|
-
}]);
|
|
113
|
-
return DiffViewer;
|
|
114
|
-
}(Component);
|
|
115
|
-
export default DiffViewer;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SDocViewer } from '../../basic-sdk';
|
|
3
|
-
import { generateDefaultDocContent } from '../../utils';
|
|
4
|
-
function HistoryVersionViewer(props) {
|
|
5
|
-
var document = props.document;
|
|
6
|
-
return /*#__PURE__*/React.createElement(SDocViewer, {
|
|
7
|
-
document: document || generateDefaultDocContent()
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
export default HistoryVersionViewer;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
-
import React, { Component } from 'react';
|
|
6
|
-
import HistoryVersionViewer from './history-version-viewer';
|
|
7
|
-
import DiffViewer from './diff-viewer';
|
|
8
|
-
var Index = /*#__PURE__*/function (_Component) {
|
|
9
|
-
_inherits(Index, _Component);
|
|
10
|
-
var _super = _createSuper(Index);
|
|
11
|
-
function Index() {
|
|
12
|
-
_classCallCheck(this, Index);
|
|
13
|
-
return _super.apply(this, arguments);
|
|
14
|
-
}
|
|
15
|
-
_createClass(Index, [{
|
|
16
|
-
key: "render",
|
|
17
|
-
value: function render() {
|
|
18
|
-
var _this$props = this.props,
|
|
19
|
-
currentContent = _this$props.currentContent,
|
|
20
|
-
lastContent = _this$props.lastContent;
|
|
21
|
-
if (!currentContent) return null;
|
|
22
|
-
if (!lastContent) {
|
|
23
|
-
return /*#__PURE__*/React.createElement(HistoryVersionViewer, {
|
|
24
|
-
document: currentContent
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return /*#__PURE__*/React.createElement(DiffViewer, this.props);
|
|
28
|
-
}
|
|
29
|
-
}]);
|
|
30
|
-
return Index;
|
|
31
|
-
}(Component);
|
|
32
|
-
export default Index;
|