@seafile/seafile-editor 2.0.48-beta2 → 2.0.48-beta4
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/editors/inline-editor/index.js +2 -1
- package/dist/editors/simple-slate-editor/index.js +2 -1
- package/dist/editors/slate-viewer/index.js +2 -1
- package/dist/extension/plugins/link/render-elem/link-popover.js +6 -12
- package/dist/hooks/user-link-click.js +9 -4
- package/dist/pages/longtext-editor-dialog/index.js +4 -2
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ var _userLinkClick = _interopRequireDefault(require("../../hooks/user-link-click
|
|
|
23
23
|
require("./index.css");
|
|
24
24
|
const isMacOS = (0, _common.isMac)();
|
|
25
25
|
const InlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
26
|
+
var _editor$api;
|
|
26
27
|
let {
|
|
27
28
|
enableEdit,
|
|
28
29
|
autoFocus,
|
|
@@ -54,7 +55,7 @@ const InlineEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
54
55
|
return new _eventHandler.default(editor);
|
|
55
56
|
}, [editor]);
|
|
56
57
|
(0, _useAttachments.default)(editor);
|
|
57
|
-
(0, _userLinkClick.default)(editor._id, onLinkClick);
|
|
58
|
+
(0, _userLinkClick.default)(editor._id, editor === null || editor === void 0 ? void 0 : (_editor$api = editor.api) === null || _editor$api === void 0 ? void 0 : _editor$api.server, onLinkClick);
|
|
58
59
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
59
60
|
const onChange = (0, _react.useCallback)(value => {
|
|
60
61
|
setSlateValue(value);
|
|
@@ -20,6 +20,7 @@ var _userLinkClick = _interopRequireDefault(require("../../hooks/user-link-click
|
|
|
20
20
|
require("./style.css");
|
|
21
21
|
const isMacOS = (0, _common.isMac)();
|
|
22
22
|
const SimpleSlateEditor = _ref => {
|
|
23
|
+
var _editor$api;
|
|
23
24
|
let {
|
|
24
25
|
value,
|
|
25
26
|
focusEnd,
|
|
@@ -44,7 +45,7 @@ const SimpleSlateEditor = _ref => {
|
|
|
44
45
|
return new _eventHandler.default(editor);
|
|
45
46
|
}, [editor]);
|
|
46
47
|
(0, _useAttachments.default)(editor);
|
|
47
|
-
(0, _userLinkClick.default)(editor._id, onLinkClick);
|
|
48
|
+
(0, _userLinkClick.default)(editor._id, editor === null || editor === void 0 ? void 0 : (_editor$api = editor.api) === null || _editor$api === void 0 ? void 0 : _editor$api.server, onLinkClick);
|
|
48
49
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
49
50
|
const onChange = (0, _react.useCallback)(value => {
|
|
50
51
|
setSlateValue(value);
|
|
@@ -17,6 +17,7 @@ var _useContainerStyle = _interopRequireDefault(require("../../hooks/use-contain
|
|
|
17
17
|
require("./style.css");
|
|
18
18
|
const isMacOS = (0, _common.isMac)();
|
|
19
19
|
function SlateViewer(_ref) {
|
|
20
|
+
var _window, _window$location;
|
|
20
21
|
let {
|
|
21
22
|
value,
|
|
22
23
|
isShowOutline,
|
|
@@ -33,7 +34,7 @@ function SlateViewer(_ref) {
|
|
|
33
34
|
}, []);
|
|
34
35
|
const containerScrollRef = externalScrollRef ? externalScrollRef : scrollRef;
|
|
35
36
|
const decorate = (0, _extension.useHighlight)(editor);
|
|
36
|
-
(0, _userLinkClick.default)(editor._id, onLinkClick);
|
|
37
|
+
(0, _userLinkClick.default)(editor._id, (_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : _window$location.origin, onLinkClick);
|
|
37
38
|
|
|
38
39
|
// willUnmount
|
|
39
40
|
(0, _react.useEffect)(() => {
|
|
@@ -11,7 +11,6 @@ var _reactDom = require("react-dom");
|
|
|
11
11
|
var _reactI18next = require("react-i18next");
|
|
12
12
|
var _eventBus = _interopRequireDefault(require("../../../../utils/event-bus"));
|
|
13
13
|
var _helper = require("../helper");
|
|
14
|
-
var _common = require("../../../../utils/common");
|
|
15
14
|
var _eventTypes = require("../../../../constants/event-types");
|
|
16
15
|
var _constants = require("../../../../constants");
|
|
17
16
|
const LinkPopover = _ref => {
|
|
@@ -30,13 +29,11 @@ const LinkPopover = _ref => {
|
|
|
30
29
|
onClosePopover();
|
|
31
30
|
};
|
|
32
31
|
}, [onClosePopover]);
|
|
33
|
-
const onLinkClick = (0, _react.useCallback)(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}, [linkUrl, editor]);
|
|
32
|
+
const onLinkClick = (0, _react.useCallback)(event => {
|
|
33
|
+
const eventBus = _eventBus.default.getInstance();
|
|
34
|
+
eventBus.dispatch(_eventTypes.EXTERNAL_EVENTS.ON_LINK_CLICK, event, editor._id);
|
|
35
|
+
onClosePopover();
|
|
36
|
+
}, [editor, onClosePopover]);
|
|
40
37
|
const onUnwrapLink = (0, _react.useCallback)(e => {
|
|
41
38
|
e.stopPropagation();
|
|
42
39
|
(0, _helper.unWrapLinkNode)(editor);
|
|
@@ -63,12 +60,9 @@ const LinkPopover = _ref => {
|
|
|
63
60
|
id: "link-op-menu",
|
|
64
61
|
className: "sf-link-op-menu",
|
|
65
62
|
style: popoverPosition
|
|
66
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
67
|
-
href: linkUrl,
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
68
64
|
"data-url": linkUrl,
|
|
69
65
|
onClick: onLinkClick,
|
|
70
|
-
target: "_blank",
|
|
71
|
-
rel: "noopener noreferrer",
|
|
72
66
|
className: "sf-link-op-menu-link"
|
|
73
67
|
}, t('Open_link')), /*#__PURE__*/_react.default.createElement("div", {
|
|
74
68
|
className: "sf-link-op-icons d-flex "
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
8
|
+
var _isUrl = _interopRequireDefault(require("is-url"));
|
|
7
9
|
const {
|
|
8
10
|
useEffect
|
|
9
11
|
} = require('react');
|
|
@@ -13,7 +15,7 @@ const {
|
|
|
13
15
|
const {
|
|
14
16
|
default: EventBus
|
|
15
17
|
} = require('../utils/event-bus');
|
|
16
|
-
const useLinkClick = (editorId, callback) => {
|
|
18
|
+
const useLinkClick = (editorId, server, callback) => {
|
|
17
19
|
useEffect(() => {
|
|
18
20
|
function onLinkClick(event, sourceEditorId) {
|
|
19
21
|
event.preventDefault();
|
|
@@ -26,15 +28,18 @@ const useLinkClick = (editorId, callback) => {
|
|
|
26
28
|
if (!target) return;
|
|
27
29
|
link = target.dataset.url;
|
|
28
30
|
if (editorId !== sourceEditorId) return;
|
|
31
|
+
if (!(0, _isUrl.default)(link)) {
|
|
32
|
+
if (link.startsWith('/') && !(0, _isUrl.default)(server + link)) return;else if (!link.startsWith('mailto:') && !link.startsWith('tel:')) return;
|
|
33
|
+
}
|
|
29
34
|
if (callback) {
|
|
30
35
|
callback(link);
|
|
31
|
-
|
|
32
|
-
window.open(link);
|
|
36
|
+
return;
|
|
33
37
|
}
|
|
38
|
+
window.open(link);
|
|
34
39
|
}
|
|
35
40
|
const eventBus = EventBus.getInstance();
|
|
36
41
|
const unsubscribe = eventBus.subscribe(EXTERNAL_EVENTS.ON_LINK_CLICK, onLinkClick);
|
|
37
42
|
return unsubscribe;
|
|
38
|
-
}, [editorId, callback]);
|
|
43
|
+
}, [editorId, server, callback]);
|
|
39
44
|
};
|
|
40
45
|
var _default = exports.default = useLinkClick;
|
|
@@ -30,7 +30,8 @@ function LongTextEditorDialog(_ref) {
|
|
|
30
30
|
editorApi,
|
|
31
31
|
onSaveEditorValue,
|
|
32
32
|
onEditorValueChanged,
|
|
33
|
-
onCloseEditorDialog
|
|
33
|
+
onCloseEditorDialog,
|
|
34
|
+
onLinkClick
|
|
34
35
|
} = _ref;
|
|
35
36
|
const editorRef = (0, _react.useRef)(null);
|
|
36
37
|
const [isValueChanged, setValueChanged] = (0, _react.useState)(false);
|
|
@@ -178,7 +179,8 @@ function LongTextEditorDialog(_ref) {
|
|
|
178
179
|
focusEnd: focusEnd,
|
|
179
180
|
editorApi: editorApi,
|
|
180
181
|
mathJaxSource: mathJaxSource,
|
|
181
|
-
onContentChanged: onContentChanged
|
|
182
|
+
onContentChanged: onContentChanged,
|
|
183
|
+
onLinkClick: onLinkClick
|
|
182
184
|
}), (readOnly || isWindowsWechat) && /*#__PURE__*/_react.default.createElement(_markdownPreview.default, {
|
|
183
185
|
isWindowsWechat: isWindowsWechat,
|
|
184
186
|
value: value,
|