@seafile/sdoc-editor 0.1.19 → 0.1.20
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/basic-sdk/assets/css/layout.css +3 -2
- package/dist/basic-sdk/assets/css/outline.css +51 -0
- package/dist/basic-sdk/editor.js +7 -1
- package/dist/basic-sdk/extension/plugins/header/render-elem.js +1 -0
- package/dist/basic-sdk/index.js +2 -1
- package/dist/basic-sdk/outline.js +114 -0
- package/dist/basic-sdk/socket/socket-client.js +5 -2
- package/dist/basic-sdk/viewer.js +4 -2
- package/dist/context.js +2 -1
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +3 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +4 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +7 -0
|
@@ -23,15 +23,16 @@
|
|
|
23
23
|
|
|
24
24
|
.sdoc-editor-container .sdoc-editor-content {
|
|
25
25
|
flex: 1;
|
|
26
|
+
display: flex;
|
|
26
27
|
background: #f5f5f5;
|
|
27
28
|
overflow: auto;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
.sdoc-editor-container .sdoc-editor-content .article {
|
|
31
|
-
|
|
32
|
+
width: 794px;
|
|
32
33
|
min-height: calc(100% - 40px);
|
|
33
|
-
margin: 20px auto;
|
|
34
34
|
padding: 40px 60px;
|
|
35
|
+
margin: 20px 0;
|
|
35
36
|
background-color: #fff;
|
|
36
37
|
border: 1px solid #e5e6e8;
|
|
37
38
|
box-shadow: 0 0 15px rgba(0, 0, 0, 0.06);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.display-outline-icon {
|
|
2
|
+
font-size: 18px;
|
|
3
|
+
color: #888;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
width: 36px;
|
|
6
|
+
height: 36px;
|
|
7
|
+
background: #fff;
|
|
8
|
+
border-radius: 0 50% 50% 0;
|
|
9
|
+
box-shadow: 0 0 6px rgba(0,0,0, 0.12);
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
margin: 20px 230px 0 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.display-outline-icon:hover {
|
|
17
|
+
color: #333;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.sdoc-outline {
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
width: 220px;
|
|
23
|
+
margin: 20px 30px 20px 16px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sdoc-outline-header {
|
|
27
|
+
color: #999;
|
|
28
|
+
border-bottom: 1px solid #dbdbdb;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.font-size-inherit {
|
|
32
|
+
font-size: inherit;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.sdoc-outline-header .close-icon {
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
font-size: 14px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.sdoc-outline-header .close-icon:hover {
|
|
41
|
+
color: #555;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.outline-item {
|
|
45
|
+
line-height: 30px;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.outline-item.active {
|
|
50
|
+
color: #ff8000;
|
|
51
|
+
}
|
package/dist/basic-sdk/editor.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Editable, Slate } from '@seafile/slate-react';
|
|
|
7
7
|
import editor, { renderLeaf as _renderLeaf, renderElement as _renderElement, Toolbar } from './extension';
|
|
8
8
|
import { SocketManager, withSocketIO } from './socket';
|
|
9
9
|
import withNodeId from './node-id';
|
|
10
|
+
import SDocOutline from './outline';
|
|
10
11
|
import EventProxy from './utils/event-handler';
|
|
11
12
|
import './assets/css/layout.css';
|
|
12
13
|
import './assets/css/sdoc-editor-plugins.css';
|
|
@@ -62,12 +63,17 @@ var SDocEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
62
63
|
value: function render() {
|
|
63
64
|
var _this2 = this;
|
|
64
65
|
var slateValue = this.state.slateValue;
|
|
66
|
+
var doc = this.props.document;
|
|
65
67
|
return /*#__PURE__*/React.createElement("div", {
|
|
66
68
|
className: "sdoc-editor-container"
|
|
67
69
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
68
70
|
editor: this.editor
|
|
69
71
|
}), /*#__PURE__*/React.createElement("div", {
|
|
70
72
|
className: "sdoc-editor-content"
|
|
73
|
+
}, /*#__PURE__*/React.createElement(SDocOutline, {
|
|
74
|
+
doc: doc
|
|
75
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: "flex-fill o-auto"
|
|
71
77
|
}, /*#__PURE__*/React.createElement(Slate, {
|
|
72
78
|
editor: this.editor,
|
|
73
79
|
value: slateValue,
|
|
@@ -83,7 +89,7 @@ var SDocEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
83
89
|
return _renderLeaf(props, _this2.editor);
|
|
84
90
|
},
|
|
85
91
|
onKeyDown: this.eventProxy.onKeyDown
|
|
86
|
-
})))));
|
|
92
|
+
}))))));
|
|
87
93
|
}
|
|
88
94
|
}]);
|
|
89
95
|
return SDocEditor;
|
|
@@ -7,6 +7,7 @@ var renderHeader = function renderHeader(props, editor) {
|
|
|
7
7
|
var level = type.split('header')[1];
|
|
8
8
|
var Tag = "h".concat(level);
|
|
9
9
|
return /*#__PURE__*/React.createElement(Tag, Object.assign({
|
|
10
|
+
id: element.id,
|
|
10
11
|
"data-id": element.id
|
|
11
12
|
}, attributes), children);
|
|
12
13
|
};
|
package/dist/basic-sdk/index.js
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
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 { withTranslation } from 'react-i18next';
|
|
7
|
+
import { UncontrolledTooltip } from 'reactstrap';
|
|
8
|
+
import './assets/css/outline.css';
|
|
9
|
+
var SDocOutline = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(SDocOutline, _React$Component);
|
|
11
|
+
var _super = _createSuper(SDocOutline);
|
|
12
|
+
function SDocOutline(props) {
|
|
13
|
+
var _this;
|
|
14
|
+
_classCallCheck(this, SDocOutline);
|
|
15
|
+
_this = _super.call(this, props);
|
|
16
|
+
_this.toggleShow = function () {
|
|
17
|
+
_this.setState({
|
|
18
|
+
isShown: !_this.state.isShown
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
_this.state = {
|
|
22
|
+
isShown: false
|
|
23
|
+
};
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
_createClass(SDocOutline, [{
|
|
27
|
+
key: "render",
|
|
28
|
+
value: function render() {
|
|
29
|
+
var _this$props = this.props,
|
|
30
|
+
doc = _this$props.doc,
|
|
31
|
+
t = _this$props.t;
|
|
32
|
+
var isShown = this.state.isShown;
|
|
33
|
+
var list = doc.children.filter(function (item) {
|
|
34
|
+
return item.type == 'header2' || item.type == 'header3';
|
|
35
|
+
});
|
|
36
|
+
return isShown ? /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: "sdoc-outline d-flex flex-column"
|
|
38
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
className: "sdoc-outline-header d-flex align-items-center justify-content-between py-1"
|
|
40
|
+
}, /*#__PURE__*/React.createElement("h2", {
|
|
41
|
+
className: "font-weight-normal m-0 font-size-inherit"
|
|
42
|
+
}, t('Outline')), /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
onClick: this.toggleShow,
|
|
44
|
+
className: "close-icon iconfont icon-cancel"
|
|
45
|
+
})), list.length ? /*#__PURE__*/React.createElement("ol", {
|
|
46
|
+
className: "list-unstyled py-2 flex-fill o-auto"
|
|
47
|
+
}, list.map(function (item, index) {
|
|
48
|
+
return /*#__PURE__*/React.createElement(OutlineItem, {
|
|
49
|
+
key: index,
|
|
50
|
+
item: item
|
|
51
|
+
});
|
|
52
|
+
})) : /*#__PURE__*/React.createElement("p", {
|
|
53
|
+
className: "mt-4 text-secondary"
|
|
54
|
+
}, t('Headings_you_add_to_the_document_will_appear_here'))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
55
|
+
onClick: this.toggleShow,
|
|
56
|
+
id: "display-outline-icon",
|
|
57
|
+
className: "display-outline-icon iconfont icon-table-of-content",
|
|
58
|
+
style: {
|
|
59
|
+
'marginRight': (window.innerWidth - 794) / 2 - 36
|
|
60
|
+
}
|
|
61
|
+
}), /*#__PURE__*/React.createElement(UncontrolledTooltip, {
|
|
62
|
+
placement: "right",
|
|
63
|
+
target: "display-outline-icon"
|
|
64
|
+
}, t('Outline')));
|
|
65
|
+
}
|
|
66
|
+
}]);
|
|
67
|
+
return SDocOutline;
|
|
68
|
+
}(React.Component);
|
|
69
|
+
var OutlineItem = /*#__PURE__*/function (_React$Component2) {
|
|
70
|
+
_inherits(OutlineItem, _React$Component2);
|
|
71
|
+
var _super2 = _createSuper(OutlineItem);
|
|
72
|
+
function OutlineItem(props) {
|
|
73
|
+
var _this2;
|
|
74
|
+
_classCallCheck(this, OutlineItem);
|
|
75
|
+
_this2 = _super2.call(this, props);
|
|
76
|
+
_this2.onItemClick = function () {
|
|
77
|
+
var item = _this2.props.item;
|
|
78
|
+
var id = item.id;
|
|
79
|
+
document.getElementById(id).scrollIntoView();
|
|
80
|
+
};
|
|
81
|
+
_this2.onMouseOver = function () {
|
|
82
|
+
_this2.setState({
|
|
83
|
+
isHighlighted: true
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
_this2.onMouseOut = function () {
|
|
87
|
+
_this2.setState({
|
|
88
|
+
isHighlighted: false
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
_this2.state = {
|
|
92
|
+
isHighlighted: false
|
|
93
|
+
};
|
|
94
|
+
return _this2;
|
|
95
|
+
}
|
|
96
|
+
_createClass(OutlineItem, [{
|
|
97
|
+
key: "render",
|
|
98
|
+
value: function render() {
|
|
99
|
+
var isHighlighted = this.state.isHighlighted;
|
|
100
|
+
var item = this.props.item;
|
|
101
|
+
var id = item.id,
|
|
102
|
+
type = item.type,
|
|
103
|
+
children = item.children;
|
|
104
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
105
|
+
className: "outline-item ".concat(type == 'header3' ? 'pl-5' : '', " ").concat(isHighlighted ? 'active' : ''),
|
|
106
|
+
onClick: this.onItemClick,
|
|
107
|
+
onMouseOver: this.onMouseOver,
|
|
108
|
+
onMouseOut: this.onMouseOut
|
|
109
|
+
}, children[0].text);
|
|
110
|
+
}
|
|
111
|
+
}]);
|
|
112
|
+
return OutlineItem;
|
|
113
|
+
}(React.Component);
|
|
114
|
+
export default withTranslation('sdoc-editor')(SDocOutline);
|
|
@@ -9,9 +9,12 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
|
|
|
9
9
|
_classCallCheck(this, SocketClient);
|
|
10
10
|
this.getParams = function () {
|
|
11
11
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
|
-
var
|
|
12
|
+
var _this$config = _this.config,
|
|
13
|
+
docUuid = _this$config.docUuid,
|
|
14
|
+
user = _this$config.user;
|
|
13
15
|
return _objectSpread({
|
|
14
|
-
doc_uuid: docUuid
|
|
16
|
+
doc_uuid: docUuid,
|
|
17
|
+
user: user
|
|
15
18
|
}, params);
|
|
16
19
|
};
|
|
17
20
|
this.onConnected = function () {
|
package/dist/basic-sdk/viewer.js
CHANGED
|
@@ -52,12 +52,14 @@ var SDocViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
52
52
|
className: "sdoc-editor-container"
|
|
53
53
|
}, /*#__PURE__*/React.createElement("div", {
|
|
54
54
|
className: "sdoc-editor-content"
|
|
55
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: "flex-fill o-auto"
|
|
55
57
|
}, /*#__PURE__*/React.createElement(Slate, {
|
|
56
58
|
editor: this.editor,
|
|
57
59
|
value: slateValue,
|
|
58
60
|
onChange: function onChange() {}
|
|
59
61
|
}, /*#__PURE__*/React.createElement("div", {
|
|
60
|
-
className: "article"
|
|
62
|
+
className: "article mx-auto"
|
|
61
63
|
}, /*#__PURE__*/React.createElement(Editable, {
|
|
62
64
|
readOnly: true,
|
|
63
65
|
placeholder: "",
|
|
@@ -73,7 +75,7 @@ var SDocViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
73
75
|
editor.handleTab && editor.handleTab(event);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
|
-
})))));
|
|
78
|
+
}))))));
|
|
77
79
|
}
|
|
78
80
|
}]);
|
|
79
81
|
return SDocViewer;
|
package/dist/context.js
CHANGED
package/package.json
CHANGED
|
@@ -233,5 +233,7 @@
|
|
|
233
233
|
"me": "me",
|
|
234
234
|
"Server_is_not_connected_Operation_will_be_sent_to_server_later": "Server is not connected. Operation will be sent to server later.",
|
|
235
235
|
"Server_is_disconnected_Reconnecting": "Server is disconnected. Reconnecting...",
|
|
236
|
-
"Server_is_reconnected": "Server is reconnected."
|
|
236
|
+
"Server_is_reconnected": "Server is reconnected.",
|
|
237
|
+
"Outline": "Outline",
|
|
238
|
+
"Headings_you_add_to_the_document_will_appear_here": "Headings you add to the document will appear here"
|
|
237
239
|
}
|
|
Binary file
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="cancel" unicode="" d="M512 441.6L214.4 742.4 185.6 768 128 710.4l25.6-28.8 300.8-297.6-300.8-297.6-25.6-28.8L185.6 0l28.8 25.6 297.6 300.8 297.6-300.8 28.8-25.6 57.6 57.6-25.6 28.8-300.8 297.6 300.8 297.6 25.6 28.8L838.4 768l-28.8-25.6-297.6-300.8z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
19
|
+
<glyph glyph-name="table-of-content" unicode="" d="M64 800h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64C28.8 672 0 700.8 0 736s28.8 64 64 64zM998.4 355.2l-12.8-12.8-172.8-172.8c-25.6-25.6-64-25.6-89.6 0s-25.6 64 0 89.6l134.4 134.4-134.4 134.4c-25.6 25.6-25.6 64 0 89.6s64 25.6 89.6 0l172.8-172.8 9.6-9.6c12.8-12.8 19.2-25.6 19.2-41.6v-3.2c0-12.8-9.6-28.8-16-35.2zM64 448h800c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64zM64 96h512c35.2 0 64-28.8 64-64s-28.8-64-64-64H64c-35.2 0-64 28.8-64 64s28.8 64 64 64z" horiz-adv-x="1024" />
|
|
20
|
+
|
|
17
21
|
<glyph glyph-name="history" unicode="" d="M544 864c265.6 0 480-214.4 480-480S809.6-96 544-96c-115.2 0-224 41.6-304 108.8-6.4 6.4-12.8 12.8-22.4 19.2l-9.6 9.6c-9.6 25.6-6.4 51.2 12.8 73.6l3.2 6.4c22.4 22.4 44.8 32 70.4 22.4l6.4-3.2 6.4-6.4c3.2-3.2 9.6-9.6 16-12.8 60.8-51.2 137.6-83.2 220.8-83.2 188.8 0 342.4 153.6 342.4 342.4S732.8 726.4 544 726.4C387.2 726.4 256 624 214.4 480h44.8c19.2 0 32-12.8 32-32 0-6.4-3.2-12.8-6.4-19.2L169.6 262.4c-9.6-12.8-28.8-19.2-44.8-6.4l-9.6 9.6L0 432c-9.6 16-6.4 35.2 9.6 44.8C16 480 22.4 480 28.8 480h44.8C115.2 697.6 304 860.8 531.2 864H544z m-6.4-224c32 0 60.8-25.6 60.8-60.8V400l115.2-89.6 3.2-3.2c22.4-19.2 22.4-54.4 3.2-76.8-22.4-25.6-60.8-25.6-86.4-6.4L476.8 348.8V582.4c0 28.8 28.8 57.6 60.8 57.6z" horiz-adv-x="1024" />
|
|
18
22
|
|
|
19
23
|
<glyph glyph-name="share" unicode="" d="M662.4 681.6c0 83.2 67.2 150.4 150.4 150.4S960 764.8 960 681.6s-67.2-150.4-150.4-150.4-147.2 70.4-147.2 150.4zM371.2 502.4l246.4 124.8c6.4-25.6 16-48 32-67.2L403.2 435.2c-3.2 25.6-16 48-32 67.2zM64 384c0 83.2 67.2 150.4 150.4 150.4S364.8 467.2 364.8 384s-67.2-150.4-150.4-150.4S64 300.8 64 384z m307.2-118.4c16 19.2 25.6 41.6 32 67.2L649.6 208c-16-19.2-25.6-41.6-32-67.2L371.2 265.6z m291.2-179.2c0 83.2 67.2 150.4 150.4 150.4s150.4-67.2 150.4-150.4S892.8-64 809.6-64s-147.2 67.2-147.2 150.4z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|