@seafile/seafile-editor 1.0.4-5 → 1.0.4-7
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.
|
@@ -5,7 +5,7 @@ import { useReadOnly } from 'slate-react';
|
|
|
5
5
|
import LinkPopover from './link-popover';
|
|
6
6
|
import { getLinkInfo } from '../helper';
|
|
7
7
|
import EventBus from '../../../../utils/event-bus';
|
|
8
|
-
import { INTERNAL_EVENTS } from '../../../../constants/event-types';
|
|
8
|
+
import { EXTERNAL_EVENTS, INTERNAL_EVENTS } from '../../../../constants/event-types';
|
|
9
9
|
import './style.css';
|
|
10
10
|
const renderLink = (_ref, editor) => {
|
|
11
11
|
let {
|
|
@@ -30,11 +30,14 @@ const renderLink = (_ref, editor) => {
|
|
|
30
30
|
const unregisterClickEvent = useCallback(() => {
|
|
31
31
|
document.removeEventListener('click', onClosePopover);
|
|
32
32
|
}, [onClosePopover]);
|
|
33
|
-
const
|
|
34
|
-
if (isReadonly) return;
|
|
33
|
+
const onLinkClick = useCallback(e => {
|
|
35
34
|
e.stopPropagation();
|
|
36
|
-
// Only one popover can be open at the same time, close other popover and update new popover controller function.
|
|
37
35
|
const eventBus = EventBus.getInstance();
|
|
36
|
+
if (isReadonly) {
|
|
37
|
+
eventBus.dispatch(EXTERNAL_EVENTS.ON_LINK_CLICK);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// Only one popover can be open at the same time, close other popover and update new popover controller function.
|
|
38
41
|
eventBus.dispatch(INTERNAL_EVENTS.ON_CLOSE_LINK_POPOVER);
|
|
39
42
|
eventBus.subscribe(INTERNAL_EVENTS.ON_CLOSE_LINK_POPOVER, () => setIsShowPopover(false));
|
|
40
43
|
const linkInfo = getLinkInfo(editor);
|
|
@@ -54,7 +57,8 @@ const renderLink = (_ref, editor) => {
|
|
|
54
57
|
registerClickEvent();
|
|
55
58
|
}, [editor, isReadonly, registerClickEvent]);
|
|
56
59
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", Object.assign({
|
|
57
|
-
onClick:
|
|
60
|
+
onClick: onLinkClick,
|
|
61
|
+
"data-url": element.url,
|
|
58
62
|
className: classNames('sf-virtual-link', {
|
|
59
63
|
selected: isShowPopover
|
|
60
64
|
})
|
|
@@ -9,6 +9,7 @@ export default function MarkdownViewer(_ref) {
|
|
|
9
9
|
value,
|
|
10
10
|
mathJaxSource,
|
|
11
11
|
isShowOutline,
|
|
12
|
+
scrollRef,
|
|
12
13
|
beforeRenderCallback
|
|
13
14
|
} = _ref;
|
|
14
15
|
const [richValue, setRichValue] = useState([]);
|
|
@@ -28,7 +29,8 @@ export default function MarkdownViewer(_ref) {
|
|
|
28
29
|
const props = {
|
|
29
30
|
isSupportFormula: !!mathJaxSource,
|
|
30
31
|
value: richValue,
|
|
31
|
-
isShowOutline: isShowOutline
|
|
32
|
+
isShowOutline: isShowOutline,
|
|
33
|
+
scrollRef: scrollRef
|
|
32
34
|
};
|
|
33
35
|
if (isFetching || isLoading || isLoadingMathJax) {
|
|
34
36
|
return /*#__PURE__*/React.createElement(Loading, null);
|