@seafile/sdoc-editor 0.5.41-beta.3 → 0.5.41-beta.5
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.js +20 -14
- 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
|
@@ -32,30 +32,36 @@ 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
|
-
const
|
|
47
|
-
changes
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
export const getMergedChanges = (topLevelChanges, diffValue) => {
|
|
42
|
+
const topLevelChangesValue = [];
|
|
43
|
+
const changes = [];
|
|
44
|
+
diffValue.forEach(item => {
|
|
45
|
+
if (topLevelChanges.includes(item.id)) {
|
|
46
|
+
const obj = {
|
|
47
|
+
id: item.id,
|
|
48
|
+
value: item
|
|
49
|
+
};
|
|
50
|
+
topLevelChangesValue.push(obj);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
topLevelChangesValue.forEach(item => {
|
|
54
|
+
var _changes;
|
|
55
|
+
const preChange = (_changes = changes[changes.length - 1]) === null || _changes === void 0 ? void 0 : _changes.value;
|
|
50
56
|
const curChange = item.value;
|
|
51
57
|
console.log('preChange', preChange);
|
|
52
58
|
console.log('curChange', curChange);
|
|
53
59
|
if ((curChange === null || curChange === void 0 ? void 0 : curChange.add) && (preChange === null || preChange === void 0 ? void 0 : preChange.add)) return;
|
|
54
60
|
if ((curChange === null || curChange === void 0 ? void 0 : curChange.delete) && (preChange === null || preChange === void 0 ? void 0 : preChange.delete)) return;
|
|
55
|
-
|
|
61
|
+
changes.push(item);
|
|
56
62
|
});
|
|
57
|
-
console.log('
|
|
58
|
-
return
|
|
63
|
+
console.log('changes', changes);
|
|
64
|
+
return changes.map(item => ({
|
|
59
65
|
id: item.id
|
|
60
66
|
}));
|
|
61
67
|
};
|
|
@@ -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 => {
|