@seafile/sdoc-editor 0.5.41-beta.11 → 0.5.41-beta.3
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 +0 -1
- package/dist/basic-sdk/utils/diff.js +14 -24
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +3 -4
- 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
|
@@ -3,7 +3,6 @@ import ObjectUtils from './object-utils';
|
|
|
3
3
|
const extendedWordChars = 'a-zA-Z\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}\\u{4e00}-\\u{9fa5}';
|
|
4
4
|
const tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), 'ug');
|
|
5
5
|
const buildValues = (diff, components, newString, oldString, valueType, useLongestToken) => {
|
|
6
|
-
console.log('buildValues', diff, components, newString, oldString, valueType, useLongestToken);
|
|
7
6
|
let componentPos = 0;
|
|
8
7
|
let componentLen = components.length;
|
|
9
8
|
let newPos = 0;
|
|
@@ -32,38 +32,30 @@ export const getTopLevelChanges = changes => {
|
|
|
32
32
|
dom = parentNode;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
const changeItem = {
|
|
36
|
+
id: dom.dataset.id,
|
|
37
|
+
value: item
|
|
38
|
+
};
|
|
39
|
+
topLevelChanges.push(changeItem);
|
|
36
40
|
});
|
|
37
|
-
return
|
|
41
|
+
return topLevelChanges;
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
// Merge consecutive added areas or deleted areas
|
|
41
|
-
export const getMergedChanges =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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;
|
|
45
|
+
export const getMergedChanges = changes => {
|
|
46
|
+
const result = [];
|
|
47
|
+
changes.forEach(item => {
|
|
48
|
+
var _result;
|
|
49
|
+
const preChange = (_result = result[result.length - 1]) === null || _result === void 0 ? void 0 : _result.value;
|
|
58
50
|
const curChange = item.value;
|
|
59
51
|
console.log('preChange', preChange);
|
|
60
52
|
console.log('curChange', curChange);
|
|
61
53
|
if ((curChange === null || curChange === void 0 ? void 0 : curChange.add) && (preChange === null || preChange === void 0 ? void 0 : preChange.add)) return;
|
|
62
54
|
if ((curChange === null || curChange === void 0 ? void 0 : curChange.delete) && (preChange === null || preChange === void 0 ? void 0 : preChange.delete)) return;
|
|
63
|
-
|
|
55
|
+
result.push(item);
|
|
64
56
|
});
|
|
65
|
-
console.log('
|
|
66
|
-
return
|
|
57
|
+
console.log('result', result);
|
|
58
|
+
return result.map(item => ({
|
|
67
59
|
id: item.id
|
|
68
60
|
}));
|
|
69
61
|
};
|
|
@@ -114,7 +106,6 @@ const getTextDiff = (element, oldElement, diff) => {
|
|
|
114
106
|
const oldText = oldElement.text;
|
|
115
107
|
const textDiff = new DiffText(oldText || '', newText || '');
|
|
116
108
|
const textDiffs = textDiff.getDiffs();
|
|
117
|
-
console.log('textDiffs', textDiffs);
|
|
118
109
|
let newChildren = [];
|
|
119
110
|
textDiffs.forEach((item, index) => {
|
|
120
111
|
const id = "".concat(element.id || slugid.nice(), "-").concat(index);
|
|
@@ -280,7 +271,6 @@ const getElementDiffValue = (currentContent, oldContent) => {
|
|
|
280
271
|
ids: oldIds
|
|
281
272
|
} = generateIdMapAndIds(oldContent);
|
|
282
273
|
const diffs = getIdDiffs(oldIds, currentIds);
|
|
283
|
-
console.log('diffs', diffs);
|
|
284
274
|
diffs.forEach(diffItem => {
|
|
285
275
|
const elementIds = diffItem.value;
|
|
286
276
|
if (diffItem.removed) {
|
|
@@ -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
|
-
allChanges
|
|
8
|
+
changes: allChanges
|
|
9
9
|
} = _ref;
|
|
10
10
|
const {
|
|
11
11
|
t
|
|
@@ -26,9 +26,8 @@ const ChangesCount = _ref => {
|
|
|
26
26
|
}, 100);
|
|
27
27
|
}).then(() => {
|
|
28
28
|
if (allChanges.length !== 0) {
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const changes = getMergedChanges(topLevelChanges, allChanges.value);
|
|
29
|
+
const topLevelChanges = getTopLevelChanges(allChanges);
|
|
30
|
+
const changes = getMergedChanges(topLevelChanges);
|
|
32
31
|
setChanges(changes);
|
|
33
32
|
}
|
|
34
33
|
});
|
|
@@ -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
|
+
changes: 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(diff);
|
|
53
|
+
setChanges((diff === null || diff === void 0 ? void 0 : diff.changes) || []);
|
|
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.changes);
|
|
44
44
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
45
|
}, [isShowChanges]);
|
|
46
46
|
const handleViewChangesToggle = useCallback(isShowChanges => {
|