@seafile/sdoc-editor 0.1.18 → 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/menu/index.js +1 -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/components/doc-operations/index.js +18 -3
- package/dist/components/tip-message/index.js +32 -0
- package/dist/components/toast/alert.js +130 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/toast.js +164 -0
- package/dist/components/toast/toastManager.js +149 -0
- package/dist/components/toast/toaster.js +65 -0
- package/dist/context.js +2 -1
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +6 -1
- package/public/locales/zh-CN/sdoc-editor.json +4 -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;
|
|
@@ -38,7 +38,7 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
38
38
|
};
|
|
39
39
|
_this.onToggleClick = function (event) {
|
|
40
40
|
event.stopPropagation();
|
|
41
|
-
event.nativeEvent.stopImmediatePropagation;
|
|
41
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
42
42
|
var isShowHeaderPopover = !_this.state.isShowHeaderPopover;
|
|
43
43
|
if (isShowHeaderPopover) {
|
|
44
44
|
_this.setState({
|
|
@@ -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;
|
|
@@ -4,25 +4,40 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import CollaboratorsOperation from './collaborators-operation';
|
|
7
|
+
import context from '../../context';
|
|
7
8
|
import './style.css';
|
|
8
9
|
var DocOperations = /*#__PURE__*/function (_React$Component) {
|
|
9
10
|
_inherits(DocOperations, _React$Component);
|
|
10
11
|
var _super = _createSuper(DocOperations);
|
|
11
12
|
function DocOperations() {
|
|
13
|
+
var _this;
|
|
12
14
|
_classCallCheck(this, DocOperations);
|
|
13
|
-
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
args[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
19
|
+
_this.toggleHistory = function (event) {
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
22
|
+
var historyURL = context.getSetting('historyURL');
|
|
23
|
+
window.location.href = historyURL;
|
|
24
|
+
};
|
|
25
|
+
return _this;
|
|
14
26
|
}
|
|
15
27
|
_createClass(DocOperations, [{
|
|
16
28
|
key: "render",
|
|
17
29
|
value: function render() {
|
|
30
|
+
var docPerm = context.getSetting('docPerm');
|
|
31
|
+
var historyURL = context.getSetting('historyURL');
|
|
18
32
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
19
33
|
className: "doc-ops"
|
|
20
34
|
}, /*#__PURE__*/React.createElement("span", {
|
|
21
35
|
className: "op-item"
|
|
22
36
|
}, /*#__PURE__*/React.createElement("i", {
|
|
23
37
|
className: "iconfont icon-share"
|
|
24
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
25
|
-
className: "op-item"
|
|
38
|
+
})), docPerm === 'rw' && historyURL && /*#__PURE__*/React.createElement("span", {
|
|
39
|
+
className: "op-item",
|
|
40
|
+
onClick: this.toggleHistory
|
|
26
41
|
}, /*#__PURE__*/React.createElement("i", {
|
|
27
42
|
className: "iconfont icon-history"
|
|
28
43
|
})), /*#__PURE__*/React.createElement(CollaboratorsOperation, null), /*#__PURE__*/React.createElement("span", {
|
|
@@ -5,6 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { withTranslation } from 'react-i18next';
|
|
7
7
|
import { EventBus } from '../../basic-sdk';
|
|
8
|
+
import toaster from '../toast';
|
|
8
9
|
import './style.css';
|
|
9
10
|
var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
10
11
|
_inherits(TipMessage, _React$Component);
|
|
@@ -13,6 +14,33 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
13
14
|
var _this;
|
|
14
15
|
_classCallCheck(this, TipMessage);
|
|
15
16
|
_this = _super.call(this, props);
|
|
17
|
+
_this.onDisconnect = function () {
|
|
18
|
+
var t = _this.props.t;
|
|
19
|
+
var message = t('Server_is_not_connected_Operation_will_be_sent_to_server_later');
|
|
20
|
+
toaster.warning(message, {
|
|
21
|
+
hasCloseButton: true,
|
|
22
|
+
duration: null
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
_this.onReconnectError = function () {
|
|
26
|
+
if (!_this.isConnectError) {
|
|
27
|
+
_this.isConnectError = true;
|
|
28
|
+
var t = _this.props.t;
|
|
29
|
+
var message = t('Server_is_disconnected_Reconnecting');
|
|
30
|
+
toaster.closeAll();
|
|
31
|
+
toaster.warning(message, {
|
|
32
|
+
hasCloseButton: true,
|
|
33
|
+
duration: null
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
_this.onReconnect = function () {
|
|
38
|
+
_this.isConnectError = false;
|
|
39
|
+
var t = _this.props.t;
|
|
40
|
+
var message = t('Server_is_reconnected');
|
|
41
|
+
toaster.closeAll();
|
|
42
|
+
toaster.success(message); // close after serval seconds
|
|
43
|
+
};
|
|
16
44
|
_this.onDocumentSaving = function () {
|
|
17
45
|
_this.setState({
|
|
18
46
|
isSaving: true,
|
|
@@ -65,6 +93,10 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
|
|
|
65
93
|
var eventBus = EventBus.getInstance();
|
|
66
94
|
this.unsubscribeSavingEvent = eventBus.subscribe('is-saving', this.onDocumentSaving);
|
|
67
95
|
this.unsubscribeSavedEvent = eventBus.subscribe('saved', this.onDocumentSaved);
|
|
96
|
+
// offline reconnect
|
|
97
|
+
this.unsubscribeDisconnectEvent = eventBus.subscribe('disconnect', this.onDisconnect);
|
|
98
|
+
this.unsubscribeReconnectErrorEvent = eventBus.subscribe('reconnect_error', this.onReconnectError);
|
|
99
|
+
this.unsubscribeReconnectEvent = eventBus.subscribe('reconnect', this.onReconnect);
|
|
68
100
|
}
|
|
69
101
|
}, {
|
|
70
102
|
key: "componentWillUnmount",
|
|
@@ -0,0 +1,130 @@
|
|
|
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 { css } from 'glamor';
|
|
7
|
+
var Alert = /*#__PURE__*/function (_React$PureComponent) {
|
|
8
|
+
_inherits(Alert, _React$PureComponent);
|
|
9
|
+
var _super = _createSuper(Alert);
|
|
10
|
+
function Alert(props) {
|
|
11
|
+
var _this;
|
|
12
|
+
_classCallCheck(this, Alert);
|
|
13
|
+
_this = _super.call(this, props);
|
|
14
|
+
_this.containerStyle = css({
|
|
15
|
+
borderRadius: '3px',
|
|
16
|
+
backgroundColor: '#fff',
|
|
17
|
+
padding: '10px 16px',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
boxSizing: 'border-box',
|
|
20
|
+
boxShadow: 'rgba(67, 90, 111, 0.3) 0px 0px 1px, rgba(67, 90, 111, 0.47) 0px 8px 10px -4px',
|
|
21
|
+
justifyContent: 'space-between',
|
|
22
|
+
flexDirection: 'row'
|
|
23
|
+
});
|
|
24
|
+
_this.containerBorderSuccess = css({
|
|
25
|
+
borderLeft: '3px solid rgb(71, 184, 129)'
|
|
26
|
+
});
|
|
27
|
+
_this.containerBorderWarn = css({
|
|
28
|
+
borderLeft: '3px solid rgb(217, 130, 43)'
|
|
29
|
+
});
|
|
30
|
+
_this.containerBorderDanger = css({
|
|
31
|
+
borderLeft: '3px solid rgb(236, 76, 71)'
|
|
32
|
+
});
|
|
33
|
+
_this.containerBorderNotify = css({
|
|
34
|
+
borderLeft: '3px solid rgb(16, 112, 202)'
|
|
35
|
+
});
|
|
36
|
+
_this.toastTextTitle = css({
|
|
37
|
+
fontWeight: '600',
|
|
38
|
+
fontSize: '14px',
|
|
39
|
+
color: '#435a6f',
|
|
40
|
+
margin: '0'
|
|
41
|
+
});
|
|
42
|
+
_this.toastTextChild = css({
|
|
43
|
+
fontSize: '14px',
|
|
44
|
+
color: '#999',
|
|
45
|
+
margin: '0'
|
|
46
|
+
});
|
|
47
|
+
_this.toastClose = css({
|
|
48
|
+
marginLeft: '15px',
|
|
49
|
+
height: '24px',
|
|
50
|
+
width: '24px',
|
|
51
|
+
lineHeight: '22px',
|
|
52
|
+
fontWeight: '700',
|
|
53
|
+
textAlign: 'center',
|
|
54
|
+
fontSize: '20px',
|
|
55
|
+
color: '#000',
|
|
56
|
+
cursor: 'pointer',
|
|
57
|
+
opacity: '0.5',
|
|
58
|
+
':hover': {
|
|
59
|
+
opacity: 1
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
_this.toastIcon = css({
|
|
63
|
+
marginRight: '10px',
|
|
64
|
+
width: '14px',
|
|
65
|
+
height: '20px',
|
|
66
|
+
lineHeight: '20px'
|
|
67
|
+
});
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
_createClass(Alert, [{
|
|
71
|
+
key: "getContainerStyle",
|
|
72
|
+
value: function getContainerStyle(intent) {
|
|
73
|
+
switch (intent) {
|
|
74
|
+
case 'success':
|
|
75
|
+
return {
|
|
76
|
+
borderStyle: this.containerBorderSuccess,
|
|
77
|
+
iconColor: css({
|
|
78
|
+
color: 'rgb(71, 184, 129)'
|
|
79
|
+
}),
|
|
80
|
+
iconClass: 'dtable-font dtable-icon-check-circle'
|
|
81
|
+
};
|
|
82
|
+
case 'warning':
|
|
83
|
+
return {
|
|
84
|
+
borderStyle: this.containerBorderWarn,
|
|
85
|
+
iconColor: css({
|
|
86
|
+
color: 'rgb(217, 130, 43)'
|
|
87
|
+
}),
|
|
88
|
+
iconClass: 'dtable-font dtable-icon-exclamation-triangle'
|
|
89
|
+
};
|
|
90
|
+
case 'none':
|
|
91
|
+
return {
|
|
92
|
+
borderStyle: this.containerBorderNotify,
|
|
93
|
+
iconColor: css({
|
|
94
|
+
color: 'rgb(16, 112, 202)'
|
|
95
|
+
}),
|
|
96
|
+
iconClass: 'dtable-font dtable-icon-description'
|
|
97
|
+
};
|
|
98
|
+
case 'danger':
|
|
99
|
+
return {
|
|
100
|
+
borderStyle: this.containerBorderDanger,
|
|
101
|
+
iconColor: css({
|
|
102
|
+
color: 'rgb(236, 76, 71)'
|
|
103
|
+
}),
|
|
104
|
+
iconClass: 'dtable-font dtable-icon-exclamation-circle'
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "render",
|
|
110
|
+
value: function render() {
|
|
111
|
+
var toastStyle = this.getContainerStyle(this.props.intent);
|
|
112
|
+
return /*#__PURE__*/React.createElement("div", css(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: this.toastIcon
|
|
114
|
+
}, /*#__PURE__*/React.createElement("i", Object.assign({
|
|
115
|
+
className: toastStyle.iconClass
|
|
116
|
+
}, toastStyle.iconColor))), /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
className: this.toastTextContainer
|
|
118
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
119
|
+
className: this.toastTextTitle
|
|
120
|
+
}, this.props.title), this.props.children ? /*#__PURE__*/React.createElement("p", {
|
|
121
|
+
className: this.toastTextChild
|
|
122
|
+
}, this.props.children) : null), this.props.isRemoveable && /*#__PURE__*/React.createElement("div", {
|
|
123
|
+
onClick: this.props.onRemove,
|
|
124
|
+
className: this.toastClose
|
|
125
|
+
}, /*#__PURE__*/React.createElement("span", null, "\xD7")));
|
|
126
|
+
}
|
|
127
|
+
}]);
|
|
128
|
+
return Alert;
|
|
129
|
+
}(React.PureComponent);
|
|
130
|
+
export default Alert;
|
|
@@ -0,0 +1,164 @@
|
|
|
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 { css } from 'glamor';
|
|
7
|
+
import Transition from 'react-transition-group/Transition';
|
|
8
|
+
import Alert from './alert';
|
|
9
|
+
var animationEasing = {
|
|
10
|
+
deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
|
|
11
|
+
acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
|
|
12
|
+
spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
|
|
13
|
+
};
|
|
14
|
+
var ANIMATION_DURATION = 240;
|
|
15
|
+
var openAnimation = css.keyframes('openAnimation', {
|
|
16
|
+
from: {
|
|
17
|
+
opacity: 0,
|
|
18
|
+
transform: 'translateY(-120%)'
|
|
19
|
+
},
|
|
20
|
+
to: {
|
|
21
|
+
transform: 'translateY(0)'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var closeAnimation = css.keyframes('closeAnimation', {
|
|
25
|
+
from: {
|
|
26
|
+
transform: 'scale(1)',
|
|
27
|
+
opacity: 1
|
|
28
|
+
},
|
|
29
|
+
to: {
|
|
30
|
+
transform: 'scale(0.9)',
|
|
31
|
+
opacity: 0
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var animationStyles = css({
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
height: 0,
|
|
39
|
+
transition: "all ".concat(ANIMATION_DURATION, "ms ").concat(animationEasing.deceleration),
|
|
40
|
+
'&[data-state="entering"], &[data-state="entered"]': {
|
|
41
|
+
animation: "".concat(openAnimation, " ").concat(ANIMATION_DURATION, "ms ").concat(animationEasing.spring, " both")
|
|
42
|
+
},
|
|
43
|
+
'&[data-state="exiting"]': {
|
|
44
|
+
animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
var Toast = /*#__PURE__*/function (_React$PureComponent) {
|
|
48
|
+
_inherits(Toast, _React$PureComponent);
|
|
49
|
+
var _super = _createSuper(Toast);
|
|
50
|
+
function Toast() {
|
|
51
|
+
var _this;
|
|
52
|
+
_classCallCheck(this, Toast);
|
|
53
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
54
|
+
args[_key] = arguments[_key];
|
|
55
|
+
}
|
|
56
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
57
|
+
_this.state = {
|
|
58
|
+
isShown: true,
|
|
59
|
+
height: 0
|
|
60
|
+
};
|
|
61
|
+
_this.close = function (event) {
|
|
62
|
+
if (event) {
|
|
63
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
}
|
|
66
|
+
_this.clearCloseTimer();
|
|
67
|
+
_this.setState({
|
|
68
|
+
isShown: false
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
_this.startCloseTimer = function () {
|
|
72
|
+
if (_this.props.duration) {
|
|
73
|
+
_this.closeTimer = setTimeout(function () {
|
|
74
|
+
_this.close();
|
|
75
|
+
}, _this.props.duration * 1000);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
_this.clearCloseTimer = function () {
|
|
79
|
+
if (_this.closeTimer) {
|
|
80
|
+
clearTimeout(_this.closeTimer);
|
|
81
|
+
_this.closeTimer = null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
_this.handleMouseEnter = function () {
|
|
85
|
+
_this.clearCloseTimer();
|
|
86
|
+
};
|
|
87
|
+
_this.handleMouseLeave = function () {
|
|
88
|
+
_this.startCloseTimer();
|
|
89
|
+
};
|
|
90
|
+
_this.onRef = function (ref) {
|
|
91
|
+
if (ref === null) return;
|
|
92
|
+
var _ref$getBoundingClien = ref.getBoundingClientRect(),
|
|
93
|
+
height = _ref$getBoundingClien.height;
|
|
94
|
+
_this.setState({
|
|
95
|
+
height: height
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
return _this;
|
|
99
|
+
}
|
|
100
|
+
_createClass(Toast, [{
|
|
101
|
+
key: "componentDidUpdate",
|
|
102
|
+
value: function componentDidUpdate(prevProps) {
|
|
103
|
+
if (prevProps.isShown !== this.props.isShown) {
|
|
104
|
+
// eslint-disable-next-line react/no-did-update-set-state
|
|
105
|
+
this.setState({
|
|
106
|
+
isShown: this.props.isShown
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "componentDidMount",
|
|
112
|
+
value: function componentDidMount() {
|
|
113
|
+
this.startCloseTimer();
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "componentWillUnmount",
|
|
117
|
+
value: function componentWillUnmount() {
|
|
118
|
+
this.clearCloseTimer();
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "render",
|
|
122
|
+
value: function render() {
|
|
123
|
+
var _this2 = this;
|
|
124
|
+
return /*#__PURE__*/React.createElement(Transition, {
|
|
125
|
+
appear: true,
|
|
126
|
+
unmountOnExit: true,
|
|
127
|
+
timeout: ANIMATION_DURATION,
|
|
128
|
+
in: this.state.isShown,
|
|
129
|
+
onExited: this.props.onRemove
|
|
130
|
+
}, function (state) {
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
"data-state": state,
|
|
133
|
+
className: animationStyles,
|
|
134
|
+
onMouseEnter: _this2.handleMouseEnter,
|
|
135
|
+
onMouseLeave: _this2.handleMouseLeave,
|
|
136
|
+
style: {
|
|
137
|
+
height: _this2.state.height,
|
|
138
|
+
zIndex: _this2.props.zIndex,
|
|
139
|
+
marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
|
|
140
|
+
}
|
|
141
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
142
|
+
ref: _this2.onRef,
|
|
143
|
+
style: {
|
|
144
|
+
padding: 8
|
|
145
|
+
}
|
|
146
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
147
|
+
intent: _this2.props.intent,
|
|
148
|
+
title: _this2.props.title,
|
|
149
|
+
"aria-label": _this2.props.title,
|
|
150
|
+
children: _this2.props.children || '',
|
|
151
|
+
isRemoveable: _this2.props.hasCloseButton,
|
|
152
|
+
onRemove: function onRemove(event) {
|
|
153
|
+
return _this2.close(event);
|
|
154
|
+
}
|
|
155
|
+
})));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}]);
|
|
159
|
+
return Toast;
|
|
160
|
+
}(React.PureComponent);
|
|
161
|
+
Toast.defaultProps = {
|
|
162
|
+
intent: 'none'
|
|
163
|
+
};
|
|
164
|
+
export { Toast as default };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
5
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
|
+
var _excluded = ["id", "description"];
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { css } from 'glamor';
|
|
12
|
+
import Toast from './toast';
|
|
13
|
+
var wrapperClass = css({
|
|
14
|
+
maxWidth: 560,
|
|
15
|
+
margin: '0 auto',
|
|
16
|
+
top: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
right: 0,
|
|
19
|
+
position: 'fixed',
|
|
20
|
+
zIndex: 30
|
|
21
|
+
});
|
|
22
|
+
var hasCustomId = function hasCustomId(settings) {
|
|
23
|
+
return Object.hasOwnProperty.call(settings, 'id');
|
|
24
|
+
};
|
|
25
|
+
var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
26
|
+
_inherits(ToastManager, _React$PureComponent);
|
|
27
|
+
var _super = _createSuper(ToastManager);
|
|
28
|
+
function ToastManager(props, context) {
|
|
29
|
+
var _this;
|
|
30
|
+
_classCallCheck(this, ToastManager);
|
|
31
|
+
_this = _super.call(this, props, context);
|
|
32
|
+
_this.getToasts = function () {
|
|
33
|
+
return _this.state.toasts;
|
|
34
|
+
};
|
|
35
|
+
_this.closeAll = function () {
|
|
36
|
+
_this.getToasts().forEach(function (toast) {
|
|
37
|
+
return toast.close();
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
_this.notify = function (title, settings) {
|
|
41
|
+
// If there's a custom toast ID passed, close existing toasts with the same custom ID
|
|
42
|
+
if (hasCustomId(settings)) {
|
|
43
|
+
var _iterator = _createForOfIteratorHelper(_this.state.toasts),
|
|
44
|
+
_step;
|
|
45
|
+
try {
|
|
46
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
47
|
+
var toast = _step.value;
|
|
48
|
+
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
|
|
49
|
+
if (String(toast.id).startsWith(settings.id)) {
|
|
50
|
+
_this.closeToast(toast.id);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
var instance = _this.createToastInstance(title, settings);
|
|
60
|
+
_this.onClose = settings.onClose;
|
|
61
|
+
_this.setState(function (previousState) {
|
|
62
|
+
return {
|
|
63
|
+
toasts: [instance].concat(_toConsumableArray(previousState.toasts))
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
return instance;
|
|
67
|
+
};
|
|
68
|
+
_this.createToastInstance = function (title, settings) {
|
|
69
|
+
var uniqueId = ++ToastManager.idCounter;
|
|
70
|
+
var id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
|
|
71
|
+
var hasCloseButton = settings.hasCloseButton || true;
|
|
72
|
+
var duration = settings.duration || 2;
|
|
73
|
+
if (settings.hasCloseButton !== undefined) {
|
|
74
|
+
hasCloseButton = settings.hasCloseButton;
|
|
75
|
+
}
|
|
76
|
+
if (settings.duration !== undefined) {
|
|
77
|
+
duration = settings.duration;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
id: id,
|
|
81
|
+
title: title,
|
|
82
|
+
description: settings.description,
|
|
83
|
+
hasCloseButton: hasCloseButton,
|
|
84
|
+
duration: duration,
|
|
85
|
+
close: function close() {
|
|
86
|
+
return _this.closeToast(id);
|
|
87
|
+
},
|
|
88
|
+
intent: settings.intent
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* This will set isShown on the Toast which will close the toast.
|
|
93
|
+
* It won't remove the toast until onExited triggers onRemove.
|
|
94
|
+
*/
|
|
95
|
+
_this.closeToast = function (id) {
|
|
96
|
+
_this.setState(function (previousState) {
|
|
97
|
+
return {
|
|
98
|
+
toasts: previousState.toasts.map(function (toast) {
|
|
99
|
+
if (toast.id === id) {
|
|
100
|
+
return _objectSpread(_objectSpread({}, toast), {}, {
|
|
101
|
+
isShown: false
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return toast;
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
_this.removeToast = function (id) {
|
|
110
|
+
_this.onClose && _this.onClose();
|
|
111
|
+
_this.setState(function (previousState) {
|
|
112
|
+
return {
|
|
113
|
+
toasts: previousState.toasts.filter(function (toast) {
|
|
114
|
+
return toast.id !== id;
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
props.bindNotify(_this.notify);
|
|
120
|
+
props.bindGetToasts(_this.getToasts);
|
|
121
|
+
props.bindCloseAll(_this.closeAll);
|
|
122
|
+
_this.state = {
|
|
123
|
+
toasts: []
|
|
124
|
+
};
|
|
125
|
+
return _this;
|
|
126
|
+
}
|
|
127
|
+
_createClass(ToastManager, [{
|
|
128
|
+
key: "render",
|
|
129
|
+
value: function render() {
|
|
130
|
+
var _this2 = this;
|
|
131
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
132
|
+
className: wrapperClass
|
|
133
|
+
}, this.state.toasts.map(function (_ref) {
|
|
134
|
+
var id = _ref.id,
|
|
135
|
+
description = _ref.description,
|
|
136
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
137
|
+
return /*#__PURE__*/React.createElement(Toast, Object.assign({
|
|
138
|
+
key: id,
|
|
139
|
+
onRemove: function onRemove() {
|
|
140
|
+
return _this2.removeToast(id);
|
|
141
|
+
}
|
|
142
|
+
}, props), description);
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}]);
|
|
146
|
+
return ToastManager;
|
|
147
|
+
}(React.PureComponent);
|
|
148
|
+
ToastManager.idCounter = 0;
|
|
149
|
+
export { ToastManager as default };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import ToastManager from './toastManager';
|
|
7
|
+
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The Toaster manages the interactionsb between
|
|
11
|
+
* the ToasterManger and the toast API.
|
|
12
|
+
*/
|
|
13
|
+
var Toaster = /*#__PURE__*/_createClass(function Toaster() {
|
|
14
|
+
var _this = this;
|
|
15
|
+
_classCallCheck(this, Toaster);
|
|
16
|
+
this._bindNotify = function (handler) {
|
|
17
|
+
_this.notifyHandler = handler;
|
|
18
|
+
};
|
|
19
|
+
this._bindGetToasts = function (handler) {
|
|
20
|
+
_this.getToastsHandler = handler;
|
|
21
|
+
};
|
|
22
|
+
this._bindCloseAll = function (handler) {
|
|
23
|
+
_this.closeAllHandler = handler;
|
|
24
|
+
};
|
|
25
|
+
this.getToasts = function () {
|
|
26
|
+
return _this.getToastsHandler();
|
|
27
|
+
};
|
|
28
|
+
this.closeAll = function () {
|
|
29
|
+
return _this.closeAllHandler();
|
|
30
|
+
};
|
|
31
|
+
this.notify = function (title) {
|
|
32
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
34
|
+
intent: 'none'
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
this.success = function (title) {
|
|
38
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
39
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
40
|
+
intent: 'success'
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
this.warning = function (title) {
|
|
44
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
46
|
+
intent: 'warning'
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
this.danger = function (title) {
|
|
50
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
51
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
52
|
+
intent: 'danger'
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
if (!isBrowser) return;
|
|
56
|
+
var container = document.createElement('div');
|
|
57
|
+
container.setAttribute('data-evergreen-toaster-container', '');
|
|
58
|
+
document.body.appendChild(container);
|
|
59
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(ToastManager, {
|
|
60
|
+
bindNotify: this._bindNotify,
|
|
61
|
+
bindGetToasts: this._bindGetToasts,
|
|
62
|
+
bindCloseAll: this._bindCloseAll
|
|
63
|
+
}), container);
|
|
64
|
+
});
|
|
65
|
+
export { Toaster as default };
|
package/dist/context.js
CHANGED
package/package.json
CHANGED
|
@@ -230,5 +230,10 @@
|
|
|
230
230
|
"Saving": "Saving...",
|
|
231
231
|
"Collaborators": "Collaborators",
|
|
232
232
|
"Online_members": "Online members",
|
|
233
|
-
"me": "me"
|
|
233
|
+
"me": "me",
|
|
234
|
+
"Server_is_not_connected_Operation_will_be_sent_to_server_later": "Server is not connected. Operation will be sent to server later.",
|
|
235
|
+
"Server_is_disconnected_Reconnecting": "Server is disconnected. Reconnecting...",
|
|
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"
|
|
234
239
|
}
|
|
@@ -225,5 +225,8 @@
|
|
|
225
225
|
"All_changes_saved": "所有更改均已保存",
|
|
226
226
|
"Saving": "保存中...",
|
|
227
227
|
"Online_members": "在线成员",
|
|
228
|
-
"me": "我"
|
|
228
|
+
"me": "我",
|
|
229
|
+
"Server_is_not_connected_Operation_will_be_sent_to_server_later": "服务器未连接。 操作稍后将发送到服务器。",
|
|
230
|
+
"Server_is_disconnected_Reconnecting": "服务器断开连接。正在重新连接...",
|
|
231
|
+
"Server_is_reconnected": "服务器已重新连接。"
|
|
229
232
|
}
|
|
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
|