@seafile/seafile-editor 2.0.27-beta2 → 2.0.27-beta3
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.
|
@@ -21,8 +21,7 @@ function SlateViewer(_ref) {
|
|
|
21
21
|
value,
|
|
22
22
|
isShowOutline,
|
|
23
23
|
scrollRef: externalScrollRef,
|
|
24
|
-
onLinkClick
|
|
25
|
-
isUseLinkClick = true
|
|
24
|
+
onLinkClick
|
|
26
25
|
} = _ref;
|
|
27
26
|
const scrollRef = (0, _react.useRef)(null);
|
|
28
27
|
const {
|
|
@@ -33,7 +32,7 @@ function SlateViewer(_ref) {
|
|
|
33
32
|
}, []);
|
|
34
33
|
const containerScrollRef = externalScrollRef ? externalScrollRef : scrollRef;
|
|
35
34
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
36
|
-
(0, _userLinkClick.default)(
|
|
35
|
+
(0, _userLinkClick.default)(editor._id, onLinkClick);
|
|
37
36
|
|
|
38
37
|
// willUnmount
|
|
39
38
|
(0, _react.useEffect)(() => {
|
package/dist/extension/editor.js
CHANGED
|
@@ -9,6 +9,7 @@ var _slate = require("slate");
|
|
|
9
9
|
var _slateHistory = require("slate-history");
|
|
10
10
|
var _slateReact = require("slate-react");
|
|
11
11
|
var _plugins = _interopRequireDefault(require("./plugins"));
|
|
12
|
+
var _slugid = require("slugid");
|
|
12
13
|
const baseEditor = exports.baseEditor = _plugins.default.reduce((editor, pluginItem) => {
|
|
13
14
|
const withPlugin = pluginItem.editorPlugin;
|
|
14
15
|
if (withPlugin) {
|
|
@@ -35,6 +36,7 @@ const createSlateEditor = () => {
|
|
|
35
36
|
}
|
|
36
37
|
return editor;
|
|
37
38
|
}, (0, _slateHistory.withHistory)((0, _slateReact.withReact)((0, _slate.createEditor)())));
|
|
39
|
+
editor._id = (0, _slugid.nice)();
|
|
38
40
|
return editor;
|
|
39
41
|
};
|
|
40
42
|
exports.createSlateEditor = createSlateEditor;
|
|
@@ -46,11 +46,7 @@ const renderLink = (_ref, editor) => {
|
|
|
46
46
|
e.stopPropagation();
|
|
47
47
|
const eventBus = _eventBus.default.getInstance();
|
|
48
48
|
if (isReadonly) {
|
|
49
|
-
|
|
50
|
-
window.open(element.url);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
eventBus.dispatch(_eventTypes.EXTERNAL_EVENTS.ON_LINK_CLICK, e);
|
|
49
|
+
eventBus.dispatch(_eventTypes.EXTERNAL_EVENTS.ON_LINK_CLICK, e, editor._id);
|
|
54
50
|
return;
|
|
55
51
|
}
|
|
56
52
|
// Only one popover can be open at the same time, close other popover and update new popover controller function.
|
|
@@ -71,7 +67,7 @@ const renderLink = (_ref, editor) => {
|
|
|
71
67
|
});
|
|
72
68
|
setIsShowPopover(true);
|
|
73
69
|
registerClickEvent();
|
|
74
|
-
}, [editor, isReadonly, registerClickEvent
|
|
70
|
+
}, [editor, isReadonly, registerClickEvent]);
|
|
75
71
|
const onHrefClick = (0, _react.useCallback)(e => {
|
|
76
72
|
e.preventDefault();
|
|
77
73
|
}, []);
|
|
@@ -13,13 +13,9 @@ const {
|
|
|
13
13
|
const {
|
|
14
14
|
default: EventBus
|
|
15
15
|
} = require('../utils/event-bus');
|
|
16
|
-
const useLinkClick =
|
|
17
|
-
let isUseLinkClick = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
18
|
-
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
16
|
+
const useLinkClick = (editorId, callback) => {
|
|
19
17
|
useEffect(() => {
|
|
20
|
-
|
|
21
|
-
if (!isUseLinkClick) return;
|
|
22
|
-
function onLinkClick(event) {
|
|
18
|
+
function onLinkClick(event, sourceEditorId) {
|
|
23
19
|
event.preventDefault();
|
|
24
20
|
event.stopPropagation();
|
|
25
21
|
let link = '';
|
|
@@ -29,6 +25,7 @@ const useLinkClick = function () {
|
|
|
29
25
|
}
|
|
30
26
|
if (!target) return;
|
|
31
27
|
link = target.dataset.url;
|
|
28
|
+
if (editorId !== sourceEditorId) return;
|
|
32
29
|
if (callback) {
|
|
33
30
|
callback(link);
|
|
34
31
|
} else {
|
|
@@ -38,6 +35,6 @@ const useLinkClick = function () {
|
|
|
38
35
|
const eventBus = EventBus.getInstance();
|
|
39
36
|
const unsubscribe = eventBus.subscribe(EXTERNAL_EVENTS.ON_LINK_CLICK, onLinkClick);
|
|
40
37
|
return unsubscribe;
|
|
41
|
-
}, [
|
|
38
|
+
}, [editorId, callback]);
|
|
42
39
|
};
|
|
43
40
|
var _default = exports.default = useLinkClick;
|
|
@@ -18,7 +18,6 @@ function MarkdownViewer(_ref) {
|
|
|
18
18
|
mathJaxSource,
|
|
19
19
|
isShowOutline,
|
|
20
20
|
scrollRef,
|
|
21
|
-
isUseLinkClick,
|
|
22
21
|
onLinkClick,
|
|
23
22
|
beforeRenderCallback
|
|
24
23
|
} = _ref;
|
|
@@ -44,7 +43,6 @@ function MarkdownViewer(_ref) {
|
|
|
44
43
|
value: richValue,
|
|
45
44
|
isShowOutline: isShowOutline,
|
|
46
45
|
scrollRef: scrollRef,
|
|
47
|
-
isUseLinkClick: isUseLinkClick,
|
|
48
46
|
onLinkClick: onLinkClick
|
|
49
47
|
};
|
|
50
48
|
if (isFetching || isLoading || isLoadingMathJax) {
|