@seafile/sdoc-editor 0.5.43 → 0.5.45
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/plugins/link/dialog/add-link-dialog/index.js +4 -2
- package/dist/basic-sdk/extension/plugins/markdown/plugin.js +6 -12
- package/dist/basic-sdk/utils/diff.js +4 -0
- package/dist/pages/published-revision-viewer.js +1 -1
- package/dist/pages/simple-editor.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { Fragment, useCallback, useState } from 'react';
|
|
1
|
+
import React, { Fragment, useCallback, useState, useMemo } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Alert, Label } from 'reactstrap';
|
|
4
|
+
import { getEditorString } from '../../../../core';
|
|
4
5
|
import { insertLink, updateLink, checkLink } from '../../helpers';
|
|
5
6
|
const AddLinkDialog = _ref => {
|
|
6
7
|
let {
|
|
@@ -23,7 +24,8 @@ const AddLinkDialog = _ref => {
|
|
|
23
24
|
title: '',
|
|
24
25
|
href: ''
|
|
25
26
|
};
|
|
26
|
-
const
|
|
27
|
+
const initTitle = useMemo(() => oldTitle ? oldTitle : getEditorString(editor, editor.selection), [editor, oldTitle]);
|
|
28
|
+
const [title, setTitle] = useState(initTitle);
|
|
27
29
|
const [url, setURL] = useState(oldURL);
|
|
28
30
|
const submit = useCallback(() => {
|
|
29
31
|
setLinkErrorMessage('');
|
|
@@ -43,21 +43,15 @@ const getBeforeText = editor => {
|
|
|
43
43
|
range: null
|
|
44
44
|
};
|
|
45
45
|
const {
|
|
46
|
-
anchor
|
|
46
|
+
anchor,
|
|
47
|
+
focus
|
|
47
48
|
} = selection;
|
|
48
|
-
// Find the block element above the current text
|
|
49
|
-
const block = Editor.above(editor, {
|
|
50
|
-
match: n => Editor.isBlock(editor, n)
|
|
51
|
-
});
|
|
52
|
-
if (block == null) return {
|
|
53
|
-
beforeText: '',
|
|
54
|
-
range: null
|
|
55
|
-
};
|
|
56
|
-
const blockPath = block[1];
|
|
57
|
-
const blockStart = Editor.start(editor, blockPath); // The starting position of the block element
|
|
58
49
|
const range = {
|
|
59
50
|
anchor,
|
|
60
|
-
focus:
|
|
51
|
+
focus: {
|
|
52
|
+
path: focus.path,
|
|
53
|
+
offset: 0
|
|
54
|
+
}
|
|
61
55
|
};
|
|
62
56
|
const beforeText = Editor.string(editor, range) || '';
|
|
63
57
|
return {
|
|
@@ -247,6 +247,10 @@ const updateDiffValue = (diff, element, oldElement) => {
|
|
|
247
247
|
}
|
|
248
248
|
const elements = getCommonDiff(element, oldElement, diff);
|
|
249
249
|
elements.forEach(item => {
|
|
250
|
+
// Changing empty characters to other characters
|
|
251
|
+
if (!item.add && item.children.find(child => child.add === true)) {
|
|
252
|
+
item.add = true;
|
|
253
|
+
}
|
|
250
254
|
diff.value.push(item);
|
|
251
255
|
});
|
|
252
256
|
};
|
|
@@ -17,7 +17,7 @@ const PublishedRevisionViewer = () => {
|
|
|
17
17
|
const [isFirstLoading, setIsFirstLoading] = useState(true);
|
|
18
18
|
const [errorMessage, setErrorMessage] = useState('');
|
|
19
19
|
const [isShowChanges, setShowChanges] = useState(false);
|
|
20
|
-
const [changes, setChanges] = useState(
|
|
20
|
+
const [changes, setChanges] = useState({});
|
|
21
21
|
const [document, setDocument] = useState({});
|
|
22
22
|
|
|
23
23
|
// useMount: reset title
|
|
@@ -29,7 +29,7 @@ const SimpleEditor = _ref => {
|
|
|
29
29
|
} = useDocument();
|
|
30
30
|
const [isShowChanges, setShowChanges] = useState(false);
|
|
31
31
|
const [revisionContent, setRevisionContent] = useState(null);
|
|
32
|
-
const [changes, setChanges] = useState(
|
|
32
|
+
const [changes, setChanges] = useState({});
|
|
33
33
|
const initIsPublished = context.getSetting('isPublished') || false;
|
|
34
34
|
const isSdocRevision = context.getSetting('isSdocRevision') || false;
|
|
35
35
|
const [isPublished, setPublished] = useState(initIsPublished);
|