@seafile/seafile-editor 0.3.76
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/README.md +119 -0
- package/TODO.md +55 -0
- package/dist/components/add-formula-dialog.js +135 -0
- package/dist/components/add-image-dialog.js +78 -0
- package/dist/components/add-link-dialog.js +148 -0
- package/dist/components/comment-dialog.js +107 -0
- package/dist/components/comment-panel.js +452 -0
- package/dist/components/context-menu.js +112 -0
- package/dist/components/detail-list-view.js +119 -0
- package/dist/components/generate-share-link.js +412 -0
- package/dist/components/internal-link-dialog.js +96 -0
- package/dist/components/loading.js +32 -0
- package/dist/components/markdown-lint.js +87 -0
- package/dist/components/modal-portal.js +46 -0
- package/dist/components/outline.js +130 -0
- package/dist/components/participants-list.js +126 -0
- package/dist/components/related-files-list.js +75 -0
- package/dist/components/shortcut-dialog.js +167 -0
- package/dist/components/side-panel.js +175 -0
- package/dist/components/toast/alert.js +150 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/toast.js +179 -0
- package/dist/components/toast/toastManager.js +158 -0
- package/dist/components/toast/toaster.js +76 -0
- package/dist/components/toolbar.js +235 -0
- package/dist/components/topbar-component/button-group.js +31 -0
- package/dist/components/topbar-component/editor-toolbar.js +545 -0
- package/dist/components/topbar-component/file-info.js +65 -0
- package/dist/components/topbar-component/header-list.js +128 -0
- package/dist/components/topbar-component/icon-button.js +99 -0
- package/dist/components/topbar-component/insert-file.js +67 -0
- package/dist/components/topbar-component/table-toolbar.js +175 -0
- package/dist/components/topbar-component/upload-img.js +122 -0
- package/dist/components/user-help.js +205 -0
- package/dist/css/diff-viewer.css +105 -0
- package/dist/css/history-viewer.css +104 -0
- package/dist/css/keyboard-shortcuts.css +59 -0
- package/dist/css/layout.css +110 -0
- package/dist/css/markdown-viewer-slate/file-tags-list.css +76 -0
- package/dist/css/markdown-viewer.css +69 -0
- package/dist/css/plaineditor/markdown-editor.css +12 -0
- package/dist/css/react-mentions-default-style.js +72 -0
- package/dist/css/related-files-list.css +56 -0
- package/dist/css/richeditor/comments-list.css +184 -0
- package/dist/css/richeditor/detail-list-view.css +114 -0
- package/dist/css/richeditor/document-info.css +57 -0
- package/dist/css/richeditor/formula.css +19 -0
- package/dist/css/richeditor/image.css +141 -0
- package/dist/css/richeditor/link.css +7 -0
- package/dist/css/richeditor/navbar-imgbutton.css +79 -0
- package/dist/css/richeditor/participants-list.css +22 -0
- package/dist/css/richeditor/rich-editor-main.css +42 -0
- package/dist/css/richeditor/right-panel.css +84 -0
- package/dist/css/richeditor/side-panel.css +190 -0
- package/dist/css/richeditor/table.css +57 -0
- package/dist/css/richeditor/textlink-hovermenu.css +47 -0
- package/dist/css/richeditor/tree-view.css +67 -0
- package/dist/css/topbar.css +400 -0
- package/dist/editor/code-highlight-package.js +27 -0
- package/dist/editor/controller/block-element-controller.js +376 -0
- package/dist/editor/controller/inline-element-controller.js +129 -0
- package/dist/editor/controller/normalize-controller.js +107 -0
- package/dist/editor/controller/shortcut-controller.js +394 -0
- package/dist/editor/controller/void-element-controller.js +12 -0
- package/dist/editor/custom/custom.js +17 -0
- package/dist/editor/custom/get-event-transfer.js +34 -0
- package/dist/editor/custom/getNodesByTypeAtRange.js +69 -0
- package/dist/editor/custom/insertNodes.js +140 -0
- package/dist/editor/custom/is-empty-paragraph.js +13 -0
- package/dist/editor/custom/set-event-transfer.js +31 -0
- package/dist/editor/custom/split-nodes-at-point.js +162 -0
- package/dist/editor/custom/unwrap-node-by-type-at-range.js +81 -0
- package/dist/editor/editor-component/check-list-item.js +64 -0
- package/dist/editor/editor-component/code-block.js +150 -0
- package/dist/editor/editor-component/formula.js +79 -0
- package/dist/editor/editor-component/image.js +215 -0
- package/dist/editor/editor-component/link.js +11 -0
- package/dist/editor/editor-component/table.js +172 -0
- package/dist/editor/editor-component/textlink-hovermenu.js +136 -0
- package/dist/editor/editor-plugin.js +249 -0
- package/dist/editor/editor-utils/block-element-utils/blockquote-utils.js +96 -0
- package/dist/editor/editor-utils/block-element-utils/code-utils.js +162 -0
- package/dist/editor/editor-utils/block-element-utils/formula-utils.js +58 -0
- package/dist/editor/editor-utils/block-element-utils/index.js +38 -0
- package/dist/editor/editor-utils/block-element-utils/list-utils.js +398 -0
- package/dist/editor/editor-utils/block-element-utils/table-utils.js +418 -0
- package/dist/editor/editor-utils/common-editor-utils.js +587 -0
- package/dist/editor/editor-utils/inline-element-utils/index.js +95 -0
- package/dist/editor/editor-utils/mark-utils.js +25 -0
- package/dist/editor/editor-utils/range-utils.js +9 -0
- package/dist/editor/editor-utils/selection-utils.js +33 -0
- package/dist/editor/editor-utils/text-utils.js +130 -0
- package/dist/editor/editor.js +66 -0
- package/dist/editor/element-model/blockquote.js +16 -0
- package/dist/editor/element-model/image.js +19 -0
- package/dist/editor/element-model/link.js +19 -0
- package/dist/editor/element-model/table.js +50 -0
- package/dist/editor/element-model/text.js +13 -0
- package/dist/editor/load-script.js +83 -0
- package/dist/editor/plain-markdown-editor.js +324 -0
- package/dist/editor/rich-markdown-editor.js +580 -0
- package/dist/editor/seafile-editor.js +326 -0
- package/dist/editor/simple-editor.js +245 -0
- package/dist/editor-api.js +261 -0
- package/dist/index.css +97 -0
- package/dist/lib/slate-hyperscript/creators.js +263 -0
- package/dist/lib/slate-hyperscript/hyperscript.js +92 -0
- package/dist/lib/slate-hyperscript/index.js +3 -0
- package/dist/lib/slate-hyperscript/tokens.js +102 -0
- package/dist/lib/unified/index.js +470 -0
- package/dist/lib/vfile/core.js +172 -0
- package/dist/lib/vfile/index.js +48 -0
- package/dist/seafile-editor-chooser.js +45 -0
- package/dist/seafile-markdown-editor.js +301 -0
- package/dist/seafile-markdown-viewer.js +79 -0
- package/dist/seafile-simple-editor.js +56 -0
- package/dist/utils/copy-to-clipboard.js +47 -0
- package/dist/utils/deserialize-html.js +282 -0
- package/dist/utils/diff/compare-strings.js +46 -0
- package/dist/utils/diff/diff.js +855 -0
- package/dist/utils/diff/index.js +2 -0
- package/dist/utils/render-slate.js +219 -0
- package/dist/utils/seafile-markdown2html.js +62 -0
- package/dist/utils/slate2markdown/deserialize.js +689 -0
- package/dist/utils/slate2markdown/index.js +3 -0
- package/dist/utils/slate2markdown/serialize.js +407 -0
- package/dist/utils/utils.js +28 -0
- package/dist/viewer/diff-viewer.js +98 -0
- package/dist/viewer/markdown-viewer.js +139 -0
- package/dist/viewer/slate-viewer.js +73 -0
- package/dist/viewer/viewer-formula.js +67 -0
- package/dist/viewer/viewer-image.js +93 -0
- package/dist/viewer/viewer-outline.js +118 -0
- package/package.json +215 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +45 -0
- package/public/locales/cs/seafile-editor.json +169 -0
- package/public/locales/de/seafile-editor.json +169 -0
- package/public/locales/en/seafile-editor.json +222 -0
- package/public/locales/es/seafile-editor.json +169 -0
- package/public/locales/es-AR/seafile-editor.json +169 -0
- package/public/locales/es-MX/seafile-editor.json +169 -0
- package/public/locales/fr/seafile-editor.json +169 -0
- package/public/locales/it/seafile-editor.json +169 -0
- package/public/locales/ru/seafile-editor.json +169 -0
- package/public/locales/zh-CN/seafile-editor.json +219 -0
- package/public/manifest.json +15 -0
- package/public/media/scripts/mathjax/tex-svg.js +1 -0
- package/public/media/seafile-editor-font/iconfont.eot +0 -0
- package/public/media/seafile-editor-font/iconfont.svg +164 -0
- package/public/media/seafile-editor-font/iconfont.ttf +0 -0
- package/public/media/seafile-editor-font/iconfont.woff +0 -0
- package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
- package/public/media/seafile-editor-font.css +201 -0
- package/public/media/seafile-logo.png +0 -0
- package/public/media/seafile-ui.css +11169 -0
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
|
|
8
|
+
var Alert = /*#__PURE__*/function (_React$PureComponent) {
|
|
9
|
+
_inherits(Alert, _React$PureComponent);
|
|
10
|
+
|
|
11
|
+
var _super = _createSuper(Alert);
|
|
12
|
+
|
|
13
|
+
function Alert(props) {
|
|
14
|
+
var _this;
|
|
15
|
+
|
|
16
|
+
_classCallCheck(this, Alert);
|
|
17
|
+
|
|
18
|
+
_this = _super.call(this, props);
|
|
19
|
+
_this.containerStyle = css({
|
|
20
|
+
borderRadius: '3px',
|
|
21
|
+
backgroundColor: '#fff',
|
|
22
|
+
padding: '10px 16px',
|
|
23
|
+
display: 'flex',
|
|
24
|
+
boxSizing: 'border-box',
|
|
25
|
+
boxShadow: 'rgba(67, 90, 111, 0.3) 0px 0px 1px, rgba(67, 90, 111, 0.47) 0px 8px 10px -4px',
|
|
26
|
+
justifyContent: 'space-between',
|
|
27
|
+
flexDirection: 'row'
|
|
28
|
+
});
|
|
29
|
+
_this.containerBorderSuccess = css({
|
|
30
|
+
borderLeft: '3px solid rgb(71, 184, 129)'
|
|
31
|
+
});
|
|
32
|
+
_this.containerBorderWarn = css({
|
|
33
|
+
borderLeft: '3px solid rgb(217, 130, 43)'
|
|
34
|
+
});
|
|
35
|
+
_this.containerBorderDanger = css({
|
|
36
|
+
borderLeft: '3px solid rgb(236, 76, 71)'
|
|
37
|
+
});
|
|
38
|
+
_this.containerBorderNotify = css({
|
|
39
|
+
borderLeft: '3px solid rgb(16, 112, 202)'
|
|
40
|
+
});
|
|
41
|
+
_this.toastTextTitle = css({
|
|
42
|
+
fontWeight: '600',
|
|
43
|
+
fontSize: '14px',
|
|
44
|
+
color: '#435a6f',
|
|
45
|
+
margin: '0'
|
|
46
|
+
});
|
|
47
|
+
_this.toastTextChild = css({
|
|
48
|
+
fontSize: '14px',
|
|
49
|
+
color: '#999',
|
|
50
|
+
margin: '0'
|
|
51
|
+
});
|
|
52
|
+
_this.toastClose = css({
|
|
53
|
+
marginLeft: '15px',
|
|
54
|
+
height: '24px',
|
|
55
|
+
width: '24px',
|
|
56
|
+
lineHeight: '22px',
|
|
57
|
+
fontWeight: '700',
|
|
58
|
+
textAlign: 'center',
|
|
59
|
+
fontSize: '20px',
|
|
60
|
+
color: '#000',
|
|
61
|
+
cursor: 'pointer',
|
|
62
|
+
opacity: '0.5',
|
|
63
|
+
':hover': {
|
|
64
|
+
opacity: 1
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
_this.toastIcon = css({
|
|
68
|
+
marginRight: '10px',
|
|
69
|
+
width: '14px',
|
|
70
|
+
height: '20px',
|
|
71
|
+
lineHeight: '20px'
|
|
72
|
+
});
|
|
73
|
+
return _this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_createClass(Alert, [{
|
|
77
|
+
key: "getContainerStyle",
|
|
78
|
+
value: function getContainerStyle(intent) {
|
|
79
|
+
switch (intent) {
|
|
80
|
+
case 'success':
|
|
81
|
+
return {
|
|
82
|
+
borderStyle: this.containerBorderSuccess,
|
|
83
|
+
iconColor: css({
|
|
84
|
+
color: 'rgb(71, 184, 129)'
|
|
85
|
+
}),
|
|
86
|
+
iconClass: 'iconfont icon-check-circle'
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
case 'warning':
|
|
90
|
+
return {
|
|
91
|
+
borderStyle: this.containerBorderWarn,
|
|
92
|
+
iconColor: css({
|
|
93
|
+
color: 'rgb(217, 130, 43)'
|
|
94
|
+
}),
|
|
95
|
+
iconClass: 'iconfont icon-exclamation-triangle'
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
case 'none':
|
|
99
|
+
return {
|
|
100
|
+
borderStyle: this.containerBorderNotify,
|
|
101
|
+
iconColor: css({
|
|
102
|
+
color: 'rgb(16, 112, 202)'
|
|
103
|
+
}),
|
|
104
|
+
iconClass: 'iconfont icon-exclamation-circle'
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
case 'danger':
|
|
108
|
+
return {
|
|
109
|
+
borderStyle: this.containerBorderDanger,
|
|
110
|
+
iconColor: css({
|
|
111
|
+
color: 'rgb(236, 76, 71)'
|
|
112
|
+
}),
|
|
113
|
+
iconClass: 'iconfont icon-exclamation-circle'
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
default:
|
|
117
|
+
return {
|
|
118
|
+
borderStyle: this.containerBorderNotify,
|
|
119
|
+
iconColor: css({
|
|
120
|
+
color: 'rgb(16, 112, 202)'
|
|
121
|
+
}),
|
|
122
|
+
iconClass: 'iconfont icon-exclamation-circle'
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "render",
|
|
128
|
+
value: function render() {
|
|
129
|
+
var toastStyle = this.getContainerStyle(this.props.intent);
|
|
130
|
+
return /*#__PURE__*/React.createElement("div", css(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
className: this.toastIcon
|
|
132
|
+
}, /*#__PURE__*/React.createElement("i", Object.assign({
|
|
133
|
+
className: toastStyle.iconClass
|
|
134
|
+
}, toastStyle.iconColor))), /*#__PURE__*/React.createElement("div", {
|
|
135
|
+
className: this.toastTextContainer
|
|
136
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
137
|
+
className: this.toastTextTitle
|
|
138
|
+
}, this.props.title), this.props.children ? /*#__PURE__*/React.createElement("p", {
|
|
139
|
+
className: this.toastTextChild
|
|
140
|
+
}, this.props.children) : null), /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
onClick: this.props.onRemove,
|
|
142
|
+
className: this.toastClose
|
|
143
|
+
}, /*#__PURE__*/React.createElement("span", null, "\xD7")));
|
|
144
|
+
}
|
|
145
|
+
}]);
|
|
146
|
+
|
|
147
|
+
return Alert;
|
|
148
|
+
}(React.PureComponent);
|
|
149
|
+
|
|
150
|
+
export default Alert;
|
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
|
|
48
|
+
var Toast = /*#__PURE__*/function (_React$PureComponent) {
|
|
49
|
+
_inherits(Toast, _React$PureComponent);
|
|
50
|
+
|
|
51
|
+
var _super = _createSuper(Toast);
|
|
52
|
+
|
|
53
|
+
function Toast() {
|
|
54
|
+
var _this;
|
|
55
|
+
|
|
56
|
+
_classCallCheck(this, Toast);
|
|
57
|
+
|
|
58
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
|
+
args[_key] = arguments[_key];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
63
|
+
_this.state = {
|
|
64
|
+
isShown: true,
|
|
65
|
+
height: 0
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_this.close = function () {
|
|
69
|
+
_this.clearCloseTimer();
|
|
70
|
+
|
|
71
|
+
_this.setState({
|
|
72
|
+
isShown: false
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
_this.startCloseTimer = function () {
|
|
77
|
+
if (_this.props.duration) {
|
|
78
|
+
_this.closeTimer = setTimeout(function () {
|
|
79
|
+
_this.close();
|
|
80
|
+
}, _this.props.duration * 1000);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
_this.clearCloseTimer = function () {
|
|
85
|
+
if (_this.closeTimer) {
|
|
86
|
+
clearTimeout(_this.closeTimer);
|
|
87
|
+
_this.closeTimer = null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
_this.handleMouseEnter = function () {
|
|
92
|
+
_this.clearCloseTimer();
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
_this.handleMouseLeave = function () {
|
|
96
|
+
_this.startCloseTimer();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
_this.onRef = function (ref) {
|
|
100
|
+
if (ref === null) return;
|
|
101
|
+
|
|
102
|
+
var _ref$getBoundingClien = ref.getBoundingClientRect(),
|
|
103
|
+
height = _ref$getBoundingClien.height;
|
|
104
|
+
|
|
105
|
+
_this.setState({
|
|
106
|
+
height: height
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return _this;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_createClass(Toast, [{
|
|
114
|
+
key: "componentDidUpdate",
|
|
115
|
+
value: function componentDidUpdate(prevProps) {
|
|
116
|
+
if (prevProps.isShown !== this.props.isShown) {
|
|
117
|
+
// eslint-disable-next-line react/no-did-update-set-state
|
|
118
|
+
this.setState({
|
|
119
|
+
isShown: this.props.isShown
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "componentDidMount",
|
|
125
|
+
value: function componentDidMount() {
|
|
126
|
+
this.startCloseTimer();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "componentWillUnmount",
|
|
130
|
+
value: function componentWillUnmount() {
|
|
131
|
+
this.clearCloseTimer();
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "render",
|
|
135
|
+
value: function render() {
|
|
136
|
+
var _this2 = this;
|
|
137
|
+
|
|
138
|
+
return /*#__PURE__*/React.createElement(Transition, {
|
|
139
|
+
appear: true,
|
|
140
|
+
unmountOnExit: true,
|
|
141
|
+
timeout: ANIMATION_DURATION,
|
|
142
|
+
in: this.state.isShown,
|
|
143
|
+
onExited: this.props.onRemove
|
|
144
|
+
}, function (state) {
|
|
145
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
"data-state": state,
|
|
147
|
+
className: animationStyles,
|
|
148
|
+
onMouseEnter: _this2.handleMouseEnter,
|
|
149
|
+
onMouseLeave: _this2.handleMouseLeave,
|
|
150
|
+
style: {
|
|
151
|
+
height: _this2.state.height,
|
|
152
|
+
zIndex: _this2.props.zIndex,
|
|
153
|
+
marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
|
|
154
|
+
}
|
|
155
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
ref: _this2.onRef,
|
|
157
|
+
style: {
|
|
158
|
+
padding: 8
|
|
159
|
+
}
|
|
160
|
+
}, /*#__PURE__*/React.createElement(Alert, {
|
|
161
|
+
intent: _this2.props.intent,
|
|
162
|
+
title: _this2.props.title,
|
|
163
|
+
children: _this2.props.children,
|
|
164
|
+
isRemoveable: _this2.props.hasCloseButton,
|
|
165
|
+
onRemove: function onRemove() {
|
|
166
|
+
return _this2.close();
|
|
167
|
+
}
|
|
168
|
+
})));
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}]);
|
|
172
|
+
|
|
173
|
+
return Toast;
|
|
174
|
+
}(React.PureComponent);
|
|
175
|
+
|
|
176
|
+
Toast.defaultProps = {
|
|
177
|
+
intent: 'none'
|
|
178
|
+
};
|
|
179
|
+
export { Toast as default };
|
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
import React from 'react';
|
|
10
|
+
import { css } from 'glamor';
|
|
11
|
+
import Toast from './toast';
|
|
12
|
+
var wrapperClass = css({
|
|
13
|
+
maxWidth: 560,
|
|
14
|
+
margin: '0 auto',
|
|
15
|
+
top: 0,
|
|
16
|
+
left: 0,
|
|
17
|
+
right: 0,
|
|
18
|
+
position: 'fixed',
|
|
19
|
+
zIndex: 30
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
var hasCustomId = function hasCustomId(settings) {
|
|
23
|
+
return Object.hasOwnProperty.call(settings, 'id');
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
|
|
27
|
+
_inherits(ToastManager, _React$PureComponent);
|
|
28
|
+
|
|
29
|
+
var _super = _createSuper(ToastManager);
|
|
30
|
+
|
|
31
|
+
function ToastManager(props, context) {
|
|
32
|
+
var _this;
|
|
33
|
+
|
|
34
|
+
_classCallCheck(this, ToastManager);
|
|
35
|
+
|
|
36
|
+
_this = _super.call(this, props, context);
|
|
37
|
+
|
|
38
|
+
_this.getToasts = function () {
|
|
39
|
+
return _this.state.toasts;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
_this.closeAll = function () {
|
|
43
|
+
_this.getToasts().forEach(function (toast) {
|
|
44
|
+
return toast.close();
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
_this.notify = function (title, settings) {
|
|
49
|
+
// If there's a custom toast ID passed, close existing toasts with the same custom ID
|
|
50
|
+
if (hasCustomId(settings)) {
|
|
51
|
+
var _iterator = _createForOfIteratorHelper(_this.state.toasts),
|
|
52
|
+
_step;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
56
|
+
var toast = _step.value;
|
|
57
|
+
|
|
58
|
+
// Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
|
|
59
|
+
if (String(toast.id).startsWith(settings.id)) {
|
|
60
|
+
_this.closeToast(toast.id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch (err) {
|
|
64
|
+
_iterator.e(err);
|
|
65
|
+
} finally {
|
|
66
|
+
_iterator.f();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var instance = _this.createToastInstance(title, settings);
|
|
71
|
+
|
|
72
|
+
_this.setState(function (previousState) {
|
|
73
|
+
return {
|
|
74
|
+
toasts: [instance].concat(_toConsumableArray(previousState.toasts))
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return instance;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
_this.createToastInstance = function (title, settings) {
|
|
82
|
+
var uniqueId = ++ToastManager.idCounter;
|
|
83
|
+
var id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
|
|
84
|
+
return {
|
|
85
|
+
id: id,
|
|
86
|
+
title: title,
|
|
87
|
+
description: settings.description,
|
|
88
|
+
hasCloseButton: settings.hasCloseButton || true,
|
|
89
|
+
duration: settings.duration || 2,
|
|
90
|
+
close: function close() {
|
|
91
|
+
return _this.closeToast(id);
|
|
92
|
+
},
|
|
93
|
+
intent: settings.intent
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
_this.closeToast = function (id) {
|
|
98
|
+
_this.setState(function (previousState) {
|
|
99
|
+
return {
|
|
100
|
+
toasts: previousState.toasts.map(function (toast) {
|
|
101
|
+
if (toast.id === id) {
|
|
102
|
+
return _objectSpread(_objectSpread({}, toast), {}, {
|
|
103
|
+
isShown: false
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return toast;
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
_this.removeToast = function (id) {
|
|
114
|
+
_this.setState(function (previousState) {
|
|
115
|
+
return {
|
|
116
|
+
toasts: previousState.toasts.filter(function (toast) {
|
|
117
|
+
return toast.id !== id;
|
|
118
|
+
})
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
props.bindNotify(_this.notify);
|
|
124
|
+
props.bindGetToasts(_this.getToasts);
|
|
125
|
+
props.bindCloseAll(_this.closeAll);
|
|
126
|
+
_this.state = {
|
|
127
|
+
toasts: []
|
|
128
|
+
};
|
|
129
|
+
return _this;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
_createClass(ToastManager, [{
|
|
133
|
+
key: "render",
|
|
134
|
+
value: function render() {
|
|
135
|
+
var _this2 = this;
|
|
136
|
+
|
|
137
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
138
|
+
className: wrapperClass
|
|
139
|
+
}, this.state.toasts.map(function (_ref) {
|
|
140
|
+
var id = _ref.id,
|
|
141
|
+
description = _ref.description,
|
|
142
|
+
props = _objectWithoutProperties(_ref, ["id", "description"]);
|
|
143
|
+
|
|
144
|
+
return /*#__PURE__*/React.createElement(Toast, Object.assign({
|
|
145
|
+
key: id,
|
|
146
|
+
onRemove: function onRemove() {
|
|
147
|
+
return _this2.removeToast(id);
|
|
148
|
+
}
|
|
149
|
+
}, props), description);
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
}]);
|
|
153
|
+
|
|
154
|
+
return ToastManager;
|
|
155
|
+
}(React.PureComponent);
|
|
156
|
+
|
|
157
|
+
ToastManager.idCounter = 0;
|
|
158
|
+
export { ToastManager as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
5
|
+
import ToastManager from './toastManager';
|
|
6
|
+
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
7
|
+
/**
|
|
8
|
+
* The Toaster manages the interactionsb between
|
|
9
|
+
* the ToasterManger and the toast API.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var Toaster = function Toaster() {
|
|
13
|
+
var _this = this;
|
|
14
|
+
|
|
15
|
+
_classCallCheck(this, Toaster);
|
|
16
|
+
|
|
17
|
+
this._bindNotify = function (handler) {
|
|
18
|
+
_this.notifyHandler = handler;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
this._bindGetToasts = function (handler) {
|
|
22
|
+
_this.getToastsHandler = handler;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
this._bindCloseAll = function (handler) {
|
|
26
|
+
_this.closeAllHandler = handler;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
this.getToasts = function () {
|
|
30
|
+
return _this.getToastsHandler();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
this.closeAll = function () {
|
|
34
|
+
return _this.closeAllHandler();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
this.notify = function (title) {
|
|
38
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
39
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
40
|
+
intent: 'none'
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
this.success = function (title) {
|
|
45
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
46
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
47
|
+
intent: 'success'
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
this.warning = function (title) {
|
|
52
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
53
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
54
|
+
intent: 'warning'
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
this.danger = function (title) {
|
|
59
|
+
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
60
|
+
return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
|
|
61
|
+
intent: 'danger'
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (!isBrowser) return;
|
|
66
|
+
var container = document.createElement('div');
|
|
67
|
+
container.setAttribute('data-evergreen-toaster-container', '');
|
|
68
|
+
document.body.appendChild(container);
|
|
69
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(ToastManager, {
|
|
70
|
+
bindNotify: this._bindNotify,
|
|
71
|
+
bindGetToasts: this._bindGetToasts,
|
|
72
|
+
bindCloseAll: this._bindCloseAll
|
|
73
|
+
}), container);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { Toaster as default };
|