@seafile/sdoc-editor 0.1.3 → 0.1.4
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/config.js +16 -0
- package/dist/index.js +2 -1
- package/dist/viewer.js +81 -0
- package/package.json +1 -1
package/dist/config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var serverConfig = {
|
|
2
|
+
//serviceUrl: "http://127.0.0.1:8000",
|
|
3
|
+
serviceUrl: "http://192.168.1.100:8000",
|
|
4
|
+
username: "lj@11.com",
|
|
5
|
+
password: "11",
|
|
6
|
+
repoID: "79d1fa93-4b5f-4d6c-8fb5-ad3958e1fa47",
|
|
7
|
+
userInfo: {
|
|
8
|
+
username: 'lj@11.com',
|
|
9
|
+
name: 'lj-',
|
|
10
|
+
contact_email: 'lj@11.com'
|
|
11
|
+
},
|
|
12
|
+
filePath: '/xxx.md',
|
|
13
|
+
fileName: 'xxx.md',
|
|
14
|
+
dirPath: '/'
|
|
15
|
+
};
|
|
16
|
+
export { serverConfig };
|
package/dist/index.js
CHANGED
package/dist/viewer.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Editable, Slate } from '@seafile/slate-react';
|
|
7
|
+
import isHotkey from 'is-hotkey';
|
|
8
|
+
import editor, { renderLeaf as _renderLeaf, renderElement as _renderElement } from './extension';
|
|
9
|
+
import { SocketManager, withSocketIO } from './socket';
|
|
10
|
+
import withNodeId from './node-id';
|
|
11
|
+
import './assets/css/sdoc-editor.css';
|
|
12
|
+
var SDocViewer = /*#__PURE__*/function (_React$Component) {
|
|
13
|
+
_inherits(SDocViewer, _React$Component);
|
|
14
|
+
var _super = _createSuper(SDocViewer);
|
|
15
|
+
function SDocViewer(props) {
|
|
16
|
+
var _this;
|
|
17
|
+
_classCallCheck(this, SDocViewer);
|
|
18
|
+
_this = _super.call(this, props);
|
|
19
|
+
var children = props.document.children;
|
|
20
|
+
_this.state = {
|
|
21
|
+
slateValue: children,
|
|
22
|
+
isLoading: true
|
|
23
|
+
};
|
|
24
|
+
_this.socketManager = null;
|
|
25
|
+
if (!props.isOpenSocket) {
|
|
26
|
+
_this.editor = withNodeId(editor);
|
|
27
|
+
} else {
|
|
28
|
+
_this.editor = withSocketIO(withNodeId(editor));
|
|
29
|
+
}
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
_createClass(SDocViewer, [{
|
|
33
|
+
key: "componentDidMount",
|
|
34
|
+
value: function componentDidMount() {
|
|
35
|
+
var _this$props = this.props,
|
|
36
|
+
isOpenSocket = _this$props.isOpenSocket,
|
|
37
|
+
document = _this$props.document,
|
|
38
|
+
config = _this$props.config;
|
|
39
|
+
if (isOpenSocket) {
|
|
40
|
+
this.socketManager = SocketManager.getInstance(this.editor, document, config);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "render",
|
|
45
|
+
value: function render() {
|
|
46
|
+
var _this2 = this;
|
|
47
|
+
var slateValue = this.state.slateValue;
|
|
48
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: "sf-editor-container"
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "sf-editor-content"
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Slate, {
|
|
53
|
+
editor: this.editor,
|
|
54
|
+
value: slateValue,
|
|
55
|
+
onChange: function onChange() {}
|
|
56
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "editor-article"
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Editable, {
|
|
59
|
+
readOnly: true,
|
|
60
|
+
placeholder: "",
|
|
61
|
+
renderElement: function renderElement(props) {
|
|
62
|
+
return _renderElement(props, _this2.editor);
|
|
63
|
+
},
|
|
64
|
+
renderLeaf: function renderLeaf(props) {
|
|
65
|
+
return _renderLeaf(props, _this2.editor);
|
|
66
|
+
},
|
|
67
|
+
onDOMBeforeInput: function onDOMBeforeInput(event) {},
|
|
68
|
+
onKeyDown: function onKeyDown(event) {
|
|
69
|
+
if (isHotkey('tab', event) || isHotkey('shift+tab', event)) {
|
|
70
|
+
editor.handleTab && editor.handleTab(event);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})))));
|
|
74
|
+
}
|
|
75
|
+
}]);
|
|
76
|
+
return SDocViewer;
|
|
77
|
+
}(React.Component);
|
|
78
|
+
SDocViewer.defaultProps = {
|
|
79
|
+
isOpenSocket: false
|
|
80
|
+
};
|
|
81
|
+
export default SDocViewer;
|