@seafile/sdoc-editor 1.0.168 → 1.0.169
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.
|
@@ -9,12 +9,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/es
|
|
|
9
9
|
class JSBridge {
|
|
10
10
|
constructor() {
|
|
11
11
|
(0, _defineProperty2.default)(this, "init", () => {
|
|
12
|
-
if (window.WebViewJavascriptBridge
|
|
13
|
-
|
|
12
|
+
if (window.WebViewJavascriptBridge) {
|
|
13
|
+
this.initWebViewJavascriptBridge();
|
|
14
14
|
} else {
|
|
15
|
-
document.addEventListener('WebViewJavascriptBridgeReady',
|
|
16
|
-
window.WebViewJavascriptBridge.init();
|
|
17
|
-
}, false);
|
|
15
|
+
document.addEventListener('WebViewJavascriptBridgeReady', this.initWebViewJavascriptBridge, false);
|
|
18
16
|
}
|
|
19
17
|
this.initJSEventHandler();
|
|
20
18
|
});
|
|
@@ -22,20 +20,21 @@ class JSBridge {
|
|
|
22
20
|
if (!window.WebViewJavascriptBridge) return;
|
|
23
21
|
window.WebViewJavascriptBridge.callHandler('finishPage');
|
|
24
22
|
});
|
|
23
|
+
(0, _defineProperty2.default)(this, "initWebViewJavascriptBridge", () => {
|
|
24
|
+
if (window.WebViewJavascriptBridge.init && !window.WebViewJavascriptBridge.inited) {
|
|
25
|
+
window.WebViewJavascriptBridge.init();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
25
28
|
(0, _defineProperty2.default)(this, "initJSEventHandler", () => {
|
|
26
|
-
console.log('aa');
|
|
27
29
|
if (!window.WebViewJavascriptBridge) return;
|
|
28
|
-
console.log('bb');
|
|
29
30
|
window.WebViewJavascriptBridge.registerHandler('callJsFunction', (sData, responseCallback) => {
|
|
30
|
-
console.log(sData, '111');
|
|
31
31
|
if (!sData) return;
|
|
32
32
|
let parsedData = null;
|
|
33
33
|
try {
|
|
34
34
|
parsedData = JSON.parse(sData);
|
|
35
|
-
console.log(parsedData);
|
|
36
35
|
} catch (err) {
|
|
37
|
-
parsedData = null;
|
|
38
36
|
console.log('parsed error');
|
|
37
|
+
parsedData = null;
|
|
39
38
|
}
|
|
40
39
|
if (!parsedData) return;
|
|
41
40
|
const {
|
|
@@ -43,7 +42,6 @@ class JSBridge {
|
|
|
43
42
|
data
|
|
44
43
|
} = parsedData;
|
|
45
44
|
const eventHandler = this.eventHandlerMap[action];
|
|
46
|
-
console.log(data);
|
|
47
45
|
const execActionSucceed = eventHandler(JSON.parse(data));
|
|
48
46
|
if (execActionSucceed) {
|
|
49
47
|
responseCallback(JSON.stringify({
|
|
@@ -99,11 +99,15 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
99
99
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
100
|
}, []);
|
|
101
101
|
(0, _react.useEffect)(() => {
|
|
102
|
-
|
|
102
|
+
const mobileLogin = _context.default.getSetting('mobileLogin');
|
|
103
|
+
if (mobileLogin) {
|
|
103
104
|
_jsBridge.default.init();
|
|
104
105
|
(0, _outlineModule.registerOutlineEventHandler)();
|
|
105
106
|
(0, _outlineModule.updateOutlineValue)(document.elements);
|
|
106
107
|
}
|
|
108
|
+
return () => {
|
|
109
|
+
_jsBridge.default.finishPage();
|
|
110
|
+
};
|
|
107
111
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
112
|
}, []);
|
|
109
113
|
const onRefreshDocument = (0, _react.useCallback)(() => {
|
|
@@ -34,11 +34,15 @@ const SDocViewer = _ref => {
|
|
|
34
34
|
const slateValue = (document || (0, _utils.generateDefaultDocContent)()).elements;
|
|
35
35
|
const Provider = showComment ? _hooks.CollaboratorsProvider : _react.Fragment;
|
|
36
36
|
(0, _react.useEffect)(() => {
|
|
37
|
-
|
|
37
|
+
const mobileLogin = _context.default.getSetting('mobileLogin');
|
|
38
|
+
if (mobileLogin) {
|
|
38
39
|
_jsBridge.default.init();
|
|
39
40
|
(0, _outlineModule.registerOutlineEventHandler)();
|
|
40
41
|
(0, _outlineModule.updateOutlineValue)(slateValue);
|
|
41
42
|
}
|
|
43
|
+
return () => {
|
|
44
|
+
_jsBridge.default.finishPage();
|
|
45
|
+
};
|
|
42
46
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
47
|
}, []);
|
|
44
48
|
return /*#__PURE__*/_react.default.createElement(Provider, null, /*#__PURE__*/_react.default.createElement(_hooks.PluginsProvider, {
|