@seafile/sdoc-editor 0.1.32 → 0.1.34
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/context.js
CHANGED
|
@@ -29,7 +29,10 @@ var Context = /*#__PURE__*/function () {
|
|
|
29
29
|
var server = this.getSetting('serviceUrl');
|
|
30
30
|
var token = this.getSetting('accessToken');
|
|
31
31
|
this.api = new SeafileAPI(server, token);
|
|
32
|
-
|
|
32
|
+
var isOpenSocket = this.getSetting('isOpenSocket');
|
|
33
|
+
if (isOpenSocket) {
|
|
34
|
+
this.sdocServerApi = new SDocServerApi(this.settings);
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
}, {
|
|
35
38
|
key: "getSettings",
|
|
@@ -9,6 +9,7 @@ import editor, { renderLeaf, renderElement } from '../../basic-sdk/extension';
|
|
|
9
9
|
import withNodeId from '../../basic-sdk/node-id';
|
|
10
10
|
import { getDiff } from '../../basic-sdk/utils/diff';
|
|
11
11
|
import { DIFF_TYPE, ELEMENT_TYPE } from '../../basic-sdk/extension/constants';
|
|
12
|
+
import context from '../../context';
|
|
12
13
|
import '../../assets/css/diff-viewer.css';
|
|
13
14
|
var DiffViewer = /*#__PURE__*/function (_Component) {
|
|
14
15
|
_inherits(DiffViewer, _Component);
|
|
@@ -81,6 +82,7 @@ var DiffViewer = /*#__PURE__*/function (_Component) {
|
|
|
81
82
|
changes: []
|
|
82
83
|
};
|
|
83
84
|
_this.editor = withNodeId(editor);
|
|
85
|
+
context.initSettings();
|
|
84
86
|
return _this;
|
|
85
87
|
}
|
|
86
88
|
_createClass(DiffViewer, [{
|
|
@@ -5,12 +5,16 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React, { Component } from 'react';
|
|
6
6
|
import HistoryVersionViewer from './history-version-viewer';
|
|
7
7
|
import DiffViewer from './diff-viewer';
|
|
8
|
+
import context from '../../context';
|
|
8
9
|
var Index = /*#__PURE__*/function (_Component) {
|
|
9
10
|
_inherits(Index, _Component);
|
|
10
11
|
var _super = _createSuper(Index);
|
|
11
|
-
function Index() {
|
|
12
|
+
function Index(props) {
|
|
13
|
+
var _this;
|
|
12
14
|
_classCallCheck(this, Index);
|
|
13
|
-
|
|
15
|
+
_this = _super.call(this, props);
|
|
16
|
+
context.initSettings();
|
|
17
|
+
return _this;
|
|
14
18
|
}
|
|
15
19
|
_createClass(Index, [{
|
|
16
20
|
key: "render",
|
|
@@ -58,13 +58,11 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
58
58
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
59
59
|
while (1) switch (_context.prev = _context.next) {
|
|
60
60
|
case 0:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
_context.prev = 2;
|
|
65
|
-
_context.next = 5;
|
|
61
|
+
context.initApi();
|
|
62
|
+
_context.prev = 1;
|
|
63
|
+
_context.next = 4;
|
|
66
64
|
return context.getFileContent();
|
|
67
|
-
case
|
|
65
|
+
case 4:
|
|
68
66
|
contentRes = _context.sent;
|
|
69
67
|
result = contentRes.data || generateDefaultDocContent();
|
|
70
68
|
if (result && !result.children) {
|
|
@@ -77,11 +75,11 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
77
75
|
isContextInit: true,
|
|
78
76
|
document: result
|
|
79
77
|
});
|
|
80
|
-
_context.next =
|
|
78
|
+
_context.next = 14;
|
|
81
79
|
break;
|
|
82
|
-
case
|
|
83
|
-
_context.prev =
|
|
84
|
-
_context.t0 = _context["catch"](
|
|
80
|
+
case 10:
|
|
81
|
+
_context.prev = 10;
|
|
82
|
+
_context.t0 = _context["catch"](1);
|
|
85
83
|
// eslint-disable-next-line
|
|
86
84
|
console.log(_context.t0);
|
|
87
85
|
this.setState({
|
|
@@ -89,11 +87,11 @@ var SimpleEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
89
87
|
errorMessage: 'load doc content error',
|
|
90
88
|
document: null
|
|
91
89
|
});
|
|
92
|
-
case
|
|
90
|
+
case 14:
|
|
93
91
|
case "end":
|
|
94
92
|
return _context.stop();
|
|
95
93
|
}
|
|
96
|
-
}, _callee, this, [[
|
|
94
|
+
}, _callee, this, [[1, 10]]);
|
|
97
95
|
}));
|
|
98
96
|
function componentDidMount() {
|
|
99
97
|
return _componentDidMount.apply(this, arguments);
|
|
@@ -37,13 +37,11 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
37
37
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
38
38
|
while (1) switch (_context.prev = _context.next) {
|
|
39
39
|
case 0:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
_context.prev = 2;
|
|
44
|
-
_context.next = 5;
|
|
40
|
+
context.initApi();
|
|
41
|
+
_context.prev = 1;
|
|
42
|
+
_context.next = 4;
|
|
45
43
|
return context.getFileContent();
|
|
46
|
-
case
|
|
44
|
+
case 4:
|
|
47
45
|
contentRes = _context.sent;
|
|
48
46
|
result = contentRes.data || generateDefaultDocContent();
|
|
49
47
|
if (result && !result.children) {
|
|
@@ -56,11 +54,11 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
56
54
|
isContextInit: true,
|
|
57
55
|
document: result
|
|
58
56
|
});
|
|
59
|
-
_context.next =
|
|
57
|
+
_context.next = 14;
|
|
60
58
|
break;
|
|
61
|
-
case
|
|
62
|
-
_context.prev =
|
|
63
|
-
_context.t0 = _context["catch"](
|
|
59
|
+
case 10:
|
|
60
|
+
_context.prev = 10;
|
|
61
|
+
_context.t0 = _context["catch"](1);
|
|
64
62
|
// eslint-disable-next-line
|
|
65
63
|
console.log(_context.t0);
|
|
66
64
|
this.setState({
|
|
@@ -68,11 +66,11 @@ var SimpleViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
68
66
|
errorMessage: 'load doc content error',
|
|
69
67
|
document: null
|
|
70
68
|
});
|
|
71
|
-
case
|
|
69
|
+
case 14:
|
|
72
70
|
case "end":
|
|
73
71
|
return _context.stop();
|
|
74
72
|
}
|
|
75
|
-
}, _callee, this, [[
|
|
73
|
+
}, _callee, this, [[1, 10]]);
|
|
76
74
|
}));
|
|
77
75
|
function componentDidMount() {
|
|
78
76
|
return _componentDidMount.apply(this, arguments);
|