@seafile/sdoc-editor 0.2.9 → 0.2.10
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.
|
@@ -211,4 +211,10 @@ export var isSdocFile = function isSdocFile(res, url) {
|
|
|
211
211
|
is_dir = _ref4.is_dir,
|
|
212
212
|
file_ext = _ref4.file_ext;
|
|
213
213
|
return !is_dir && file_ext === 'sdoc';
|
|
214
|
+
};
|
|
215
|
+
export var isWeChat = function isWeChat() {
|
|
216
|
+
var ua = window.navigator.userAgent.toLowerCase();
|
|
217
|
+
var isWeChat = ua.match(/MicroMessenger/i) === 'micromessenger';
|
|
218
|
+
var isEnterpriseWeChat = ua.match(/MicroMessenger/i) === 'micromessenger' && ua.match(/wxwork/i) === 'wxwork';
|
|
219
|
+
return isEnterpriseWeChat || isWeChat;
|
|
214
220
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { isWeChat } from '../helpers';
|
|
4
5
|
import '../../../../assets/css/textlink-hovermenu.css';
|
|
5
6
|
var LinkHover = function LinkHover(_ref) {
|
|
6
7
|
var editor = _ref.editor,
|
|
@@ -12,14 +13,19 @@ var LinkHover = function LinkHover(_ref) {
|
|
|
12
13
|
t = _useTranslation.t;
|
|
13
14
|
var onMouseDown = useCallback(function (event) {
|
|
14
15
|
event.stopPropagation();
|
|
15
|
-
|
|
16
|
+
if (!isWeChat()) {
|
|
17
|
+
window.open(element.href);
|
|
18
|
+
} else {
|
|
19
|
+
// eslint-disable-next-line no-restricted-globals
|
|
20
|
+
location.href = element.href;
|
|
21
|
+
}
|
|
22
|
+
}, [element.href]);
|
|
16
23
|
return /*#__PURE__*/React.createElement(React.Fragment, null, createPortal( /*#__PURE__*/React.createElement("div", {
|
|
17
24
|
id: "link-op-menu",
|
|
18
25
|
className: "link-op-menu",
|
|
19
26
|
style: menuPosition,
|
|
20
27
|
onMouseDown: onMouseDown
|
|
21
|
-
}, /*#__PURE__*/React.createElement("
|
|
22
|
-
href: element.href,
|
|
28
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
23
29
|
target: "_blank",
|
|
24
30
|
rel: "noopener noreferrer",
|
|
25
31
|
className: "link-op-menu-link"
|
|
@@ -88,8 +88,8 @@ var LinkHoverMenuComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
88
88
|
className: className
|
|
89
89
|
}, attributes, {
|
|
90
90
|
onClick: this.onLinkClick
|
|
91
|
-
}), /*#__PURE__*/React.createElement("
|
|
92
|
-
|
|
91
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
92
|
+
className: "virtual-link",
|
|
93
93
|
title: element.title
|
|
94
94
|
}, children)), isShowLinkMenu && Range.isCollapsed(editor.selection) && /*#__PURE__*/React.createElement(LinkHover, {
|
|
95
95
|
editor: editor,
|