@seafile/sdoc-editor 1.0.167 → 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 && !window.WebViewJavascriptBridge.inited) {
13
- window.WebViewJavascriptBridge.init();
12
+ if (window.WebViewJavascriptBridge) {
13
+ this.initWebViewJavascriptBridge();
14
14
  } else {
15
- document.addEventListener('WebViewJavascriptBridgeReady', function () {
16
- window.WebViewJavascriptBridge.init();
17
- }, false);
15
+ document.addEventListener('WebViewJavascriptBridgeReady', this.initWebViewJavascriptBridge, false);
18
16
  }
19
17
  this.initJSEventHandler();
20
18
  });
@@ -22,18 +20,20 @@ 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) {
36
+ console.log('parsed error');
37
37
  parsedData = null;
38
38
  }
39
39
  if (!parsedData) return;
@@ -42,7 +42,6 @@ class JSBridge {
42
42
  data
43
43
  } = parsedData;
44
44
  const eventHandler = this.eventHandlerMap[action];
45
- console.log(data);
46
45
  const execActionSucceed = eventHandler(JSON.parse(data));
47
46
  if (execActionSucceed) {
48
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
- if (_utils.isMobile) {
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
- if (_utils.isMobile) {
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, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "1.0.167",
3
+ "version": "1.0.169",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",