@seafile/sdoc-editor 0.5.41-beta.1 → 0.5.41-beta.10
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/utils/diff-text.js +1 -0
- package/dist/basic-sdk/utils/diff.js +28 -14
- package/dist/basic-sdk/views/revision-diff-viewer.js +0 -1
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +4 -3
- package/dist/components/doc-operations/revision-operations/index.js +1 -1
- package/dist/pages/published-revision-viewer.js +1 -1
- package/dist/pages/simple-editor.js +1 -1
- package/package.json +1 -1
|
@@ -123,6 +123,7 @@ class DiffText {
|
|
|
123
123
|
}, 0);
|
|
124
124
|
});
|
|
125
125
|
_defineProperty(this, "pushComponent", (components, added, removed) => {
|
|
126
|
+
console.log('pushComponent-add-remove', components, added, removed);
|
|
126
127
|
let last = components[components.length - 1];
|
|
127
128
|
if (last && last.added === added && last.removed === removed) {
|
|
128
129
|
// We need to clone here as the component clone operation is just
|
|
@@ -32,28 +32,40 @@ export const getTopLevelChanges = changes => {
|
|
|
32
32
|
dom = parentNode;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
id: dom.dataset.id,
|
|
37
|
-
value: item
|
|
38
|
-
};
|
|
39
|
-
topLevelChanges.push(changeItem);
|
|
35
|
+
topLevelChanges.push(dom.dataset.id);
|
|
40
36
|
});
|
|
41
|
-
return topLevelChanges;
|
|
37
|
+
return Array.from(new Set(topLevelChanges));
|
|
42
38
|
};
|
|
43
39
|
|
|
44
40
|
// Merge consecutive added areas or deleted areas
|
|
45
|
-
export const getMergedChanges =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
export const getMergedChanges = (topLevelChanges, diffValue) => {
|
|
42
|
+
console.log('topLevelChanges', topLevelChanges);
|
|
43
|
+
const topLevelChangesValue = [];
|
|
44
|
+
const changes = [];
|
|
45
|
+
diffValue.forEach(item => {
|
|
46
|
+
if (topLevelChanges.includes(item.id)) {
|
|
47
|
+
const obj = {
|
|
48
|
+
id: item.id,
|
|
49
|
+
value: item
|
|
50
|
+
};
|
|
51
|
+
topLevelChangesValue.push(obj);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
console.log('topLevelChangesValue', topLevelChangesValue);
|
|
55
|
+
topLevelChangesValue.forEach(item => {
|
|
56
|
+
var _changes;
|
|
57
|
+
const preChange = (_changes = changes[changes.length - 1]) === null || _changes === void 0 ? void 0 : _changes.value;
|
|
50
58
|
const curChange = item.value;
|
|
59
|
+
console.log('preChange', preChange);
|
|
60
|
+
console.log('curChange', curChange);
|
|
51
61
|
if ((curChange === null || curChange === void 0 ? void 0 : curChange.add) && (preChange === null || preChange === void 0 ? void 0 : preChange.add)) return;
|
|
52
62
|
if ((curChange === null || curChange === void 0 ? void 0 : curChange.delete) && (preChange === null || preChange === void 0 ? void 0 : preChange.delete)) return;
|
|
53
|
-
|
|
63
|
+
changes.push(item);
|
|
54
64
|
});
|
|
55
|
-
console.log('
|
|
56
|
-
return
|
|
65
|
+
console.log('changes', changes);
|
|
66
|
+
return changes.map(item => ({
|
|
67
|
+
id: item.id
|
|
68
|
+
}));
|
|
57
69
|
};
|
|
58
70
|
|
|
59
71
|
// Depth facilitates each child node, adding diffType to each end node
|
|
@@ -102,6 +114,7 @@ const getTextDiff = (element, oldElement, diff) => {
|
|
|
102
114
|
const oldText = oldElement.text;
|
|
103
115
|
const textDiff = new DiffText(oldText || '', newText || '');
|
|
104
116
|
const textDiffs = textDiff.getDiffs();
|
|
117
|
+
console.log('textDiffs', textDiffs);
|
|
105
118
|
let newChildren = [];
|
|
106
119
|
textDiffs.forEach((item, index) => {
|
|
107
120
|
const id = "".concat(element.id || slugid.nice(), "-").concat(index);
|
|
@@ -267,6 +280,7 @@ const getElementDiffValue = (currentContent, oldContent) => {
|
|
|
267
280
|
ids: oldIds
|
|
268
281
|
} = generateIdMapAndIds(oldContent);
|
|
269
282
|
const diffs = getIdDiffs(oldIds, currentIds);
|
|
283
|
+
console.log('diffs', diffs);
|
|
270
284
|
diffs.forEach(diffItem => {
|
|
271
285
|
const elementIds = diffItem.value;
|
|
272
286
|
if (diffItem.removed) {
|
|
@@ -21,7 +21,6 @@ const RevisionDiffViewer = _ref => {
|
|
|
21
21
|
} = res.data;
|
|
22
22
|
const originContent = JSON.parse(originContentString);
|
|
23
23
|
const diff = getDiff(revisionContent, originContent);
|
|
24
|
-
console.log('diff', diff);
|
|
25
24
|
setDiff(diff);
|
|
26
25
|
didMountCallback && didMountCallback(diff);
|
|
27
26
|
setIsLoading(false);
|
|
@@ -5,7 +5,7 @@ import { getTopLevelChanges, getMergedChanges } from '../../../../basic-sdk/util
|
|
|
5
5
|
import './index.css';
|
|
6
6
|
const ChangesCount = _ref => {
|
|
7
7
|
let {
|
|
8
|
-
|
|
8
|
+
allChanges
|
|
9
9
|
} = _ref;
|
|
10
10
|
const {
|
|
11
11
|
t
|
|
@@ -26,8 +26,9 @@ const ChangesCount = _ref => {
|
|
|
26
26
|
}, 100);
|
|
27
27
|
}).then(() => {
|
|
28
28
|
if (allChanges.length !== 0) {
|
|
29
|
-
|
|
30
|
-
const
|
|
29
|
+
console.log('allChanges', allChanges);
|
|
30
|
+
const topLevelChanges = getTopLevelChanges(allChanges.changes);
|
|
31
|
+
const changes = getMergedChanges(topLevelChanges, allChanges.value);
|
|
31
32
|
setChanges(changes);
|
|
32
33
|
}
|
|
33
34
|
});
|
|
@@ -192,7 +192,7 @@ const RevisionOperations = _ref => {
|
|
|
192
192
|
setShowTip(false);
|
|
193
193
|
}, []);
|
|
194
194
|
return /*#__PURE__*/React.createElement(React.Fragment, null, !isSdocRevision && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MoreRevisionOperations, null), /*#__PURE__*/React.createElement(Revisions, null)), isSdocRevision && isShowChanges && /*#__PURE__*/React.createElement(ChangesCount, {
|
|
195
|
-
|
|
195
|
+
allChanges: changes
|
|
196
196
|
}), isSdocRevision && /*#__PURE__*/React.createElement(ViewChanges, {
|
|
197
197
|
isShowChanges: isShowChanges,
|
|
198
198
|
onViewChangesToggle: onViewChangesToggle
|
|
@@ -50,7 +50,7 @@ const PublishedRevisionViewer = () => {
|
|
|
50
50
|
});
|
|
51
51
|
}, []);
|
|
52
52
|
const setDiffChanges = useCallback(diff => {
|
|
53
|
-
setChanges(
|
|
53
|
+
setChanges(diff);
|
|
54
54
|
}, []);
|
|
55
55
|
const handleViewChangesToggle = useCallback(isShowChanges => {
|
|
56
56
|
setShowChanges(isShowChanges);
|
|
@@ -40,7 +40,7 @@ const SimpleEditor = _ref => {
|
|
|
40
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
41
|
}, []);
|
|
42
42
|
const setDiffChanges = useCallback(diff => {
|
|
43
|
-
setChanges(diff
|
|
43
|
+
setChanges(diff);
|
|
44
44
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
45
|
}, [isShowChanges]);
|
|
46
46
|
const handleViewChangesToggle = useCallback(isShowChanges => {
|