@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,452 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import moment from 'moment';
|
|
8
|
+
import { processor } from '../utils/seafile-markdown2html';
|
|
9
|
+
import { Button, Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
|
|
10
|
+
import ParticipantsList from './participants-list';
|
|
11
|
+
import toaster from '../components/toast';
|
|
12
|
+
import { MentionsInput, Mention } from 'react-mentions';
|
|
13
|
+
import { defaultStyle } from '../css/react-mentions-default-style';
|
|
14
|
+
import '../css/richeditor/comments-list.css';
|
|
15
|
+
|
|
16
|
+
var CommentPanel = /*#__PURE__*/function (_React$Component) {
|
|
17
|
+
_inherits(CommentPanel, _React$Component);
|
|
18
|
+
|
|
19
|
+
var _super = _createSuper(CommentPanel);
|
|
20
|
+
|
|
21
|
+
function CommentPanel(props) {
|
|
22
|
+
var _this;
|
|
23
|
+
|
|
24
|
+
_classCallCheck(this, CommentPanel);
|
|
25
|
+
|
|
26
|
+
_this = _super.call(this, props);
|
|
27
|
+
|
|
28
|
+
_this.toggleResolvedComment = function () {
|
|
29
|
+
_this.setState({
|
|
30
|
+
showResolvedComment: !_this.state.showResolvedComment
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_this.listComments = function (isScroll) {
|
|
35
|
+
_this.props.editorApi.listComments().then(function (res) {
|
|
36
|
+
_this.setState({
|
|
37
|
+
commentsList: res.data.comments
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (isScroll) {
|
|
41
|
+
var that = _assertThisInitialized(_this);
|
|
42
|
+
|
|
43
|
+
setTimeout(function () {
|
|
44
|
+
that.refs.commentsList.scrollTo(0, 10000);
|
|
45
|
+
}, 100);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
_this.handleCommentChange = function (event) {
|
|
51
|
+
_this.setState({
|
|
52
|
+
comment: event.target.value
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
_this.resolveComment = function (event) {
|
|
57
|
+
_this.props.editorApi.updateComment(event.target.id, 'true').then(function () {
|
|
58
|
+
_this.listComments();
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
_this.deleteComment = function (event) {
|
|
63
|
+
_this.props.editorApi.deleteComment(event.target.id).then(function () {
|
|
64
|
+
_this.listComments();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_this.editComment = function (commentID, newComment) {
|
|
69
|
+
_this.props.editorApi.updateComment(commentID, null, null, newComment).then(function (res) {
|
|
70
|
+
_this.listComments();
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
_this.listRepoRelatedUsers = function () {
|
|
75
|
+
if (!window.showParticipants) return;
|
|
76
|
+
|
|
77
|
+
_this.props.editorApi.listRepoRelatedUsers().then(function (res) {
|
|
78
|
+
var users = res.data.user_list.map(function (item) {
|
|
79
|
+
return {
|
|
80
|
+
id: item.email,
|
|
81
|
+
display: item.name
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
_this.setState({
|
|
86
|
+
relatedUsers: users
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
_this.addComment = function () {
|
|
92
|
+
if (!_this.state.comment.trim()) return;
|
|
93
|
+
|
|
94
|
+
_this.props.editorApi.postComment(_this.state.comment.trim()).then(function () {
|
|
95
|
+
_this.listComments(true);
|
|
96
|
+
}).catch(function (err) {
|
|
97
|
+
if (err.response.data) {
|
|
98
|
+
toaster.danger(err.response.data['error_msg'], {
|
|
99
|
+
duration: 3
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
_this.setState({
|
|
105
|
+
comment: ''
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
_this.onSubmit = function () {
|
|
110
|
+
if (window.showParticipants) {
|
|
111
|
+
_this.addParticipant(_this.props.editorApi.userName);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (_this.toBeAddedParticipant.length === 0 || !window.showParticipants) {
|
|
115
|
+
_this.addComment();
|
|
116
|
+
} else {
|
|
117
|
+
_this.props.editorApi.addFileParticipants(_this.toBeAddedParticipant).then(function (res) {
|
|
118
|
+
_this.toBeAddedParticipant = [];
|
|
119
|
+
|
|
120
|
+
_this.addComment();
|
|
121
|
+
|
|
122
|
+
_this.props.onParticipantsChange();
|
|
123
|
+
}).catch(function (err) {
|
|
124
|
+
if (err.response.data) {
|
|
125
|
+
toaster.danger(err.response.data['error_msg'], {
|
|
126
|
+
duration: 3
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
_this.checkParticipant = function (email) {
|
|
134
|
+
return _this.props.participants.map(function (participant) {
|
|
135
|
+
return participant.email;
|
|
136
|
+
}).includes(email);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
_this.addParticipant = function (email) {
|
|
140
|
+
if (_this.checkParticipant(email)) return;
|
|
141
|
+
|
|
142
|
+
_this.toBeAddedParticipant.push(email);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
_this.renderUserSuggestion = function (entry, search, highlightedDisplay, index, focused) {
|
|
146
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: "user ".concat(focused ? 'focused' : '')
|
|
148
|
+
}, highlightedDisplay);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
_this.state = {
|
|
152
|
+
commentsList: [],
|
|
153
|
+
showResolvedComment: true,
|
|
154
|
+
comment: '',
|
|
155
|
+
relatedUsers: null
|
|
156
|
+
};
|
|
157
|
+
_this.toBeAddedParticipant = [];
|
|
158
|
+
return _this;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
_createClass(CommentPanel, [{
|
|
162
|
+
key: "componentDidMount",
|
|
163
|
+
value: function componentDidMount() {
|
|
164
|
+
this.listComments();
|
|
165
|
+
this.listRepoRelatedUsers();
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "componentWillReceiveProps",
|
|
169
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
170
|
+
if (this.props.relistComment !== nextProps.relistComment) this.listComments(true);
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "render",
|
|
174
|
+
value: function render() {
|
|
175
|
+
var _this2 = this;
|
|
176
|
+
|
|
177
|
+
var t = this.props.t;
|
|
178
|
+
var participants = this.props.participants;
|
|
179
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
180
|
+
className: "seafile-comment"
|
|
181
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
182
|
+
className: "seafile-comment-toggle-resolved"
|
|
183
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
184
|
+
className: 'seafile-comment-title-text'
|
|
185
|
+
}, t('Show_resolved_comments')), /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
className: 'seafile-comment-title-toggle d-flex'
|
|
187
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
188
|
+
className: "custom-switch",
|
|
189
|
+
id: "toggle-resolved-comments"
|
|
190
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
191
|
+
type: "checkbox",
|
|
192
|
+
name: "option",
|
|
193
|
+
className: "custom-switch-input",
|
|
194
|
+
onChange: this.toggleResolvedComment,
|
|
195
|
+
checked: this.state.showResolvedComment && 'checked'
|
|
196
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
197
|
+
className: "custom-switch-indicator"
|
|
198
|
+
})))), /*#__PURE__*/React.createElement("ul", {
|
|
199
|
+
className: window.showParticipants ? 'seafile-comment-list show-participants' : 'seafile-comment-list',
|
|
200
|
+
ref: "commentsList"
|
|
201
|
+
}, this.state.commentsList.length > 0 && this.state.commentsList.map(function (item) {
|
|
202
|
+
var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
203
|
+
var arr = arguments.length > 2 ? arguments[2] : undefined;
|
|
204
|
+
var oldTime = new Date(item.created_at).getTime();
|
|
205
|
+
var time = moment(oldTime).format('YYYY-MM-DD HH:mm');
|
|
206
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
207
|
+
key: item.id
|
|
208
|
+
}, /*#__PURE__*/React.createElement(CommentItem, {
|
|
209
|
+
item: item,
|
|
210
|
+
time: time,
|
|
211
|
+
t: _this2.props.t,
|
|
212
|
+
deleteComment: _this2.deleteComment,
|
|
213
|
+
resolveComment: _this2.resolveComment,
|
|
214
|
+
editComment: _this2.editComment,
|
|
215
|
+
showResolvedComment: _this2.state.showResolvedComment,
|
|
216
|
+
editorApi: _this2.props.editorApi,
|
|
217
|
+
scrollToQuote: _this2.props.scrollToQuote
|
|
218
|
+
}));
|
|
219
|
+
}), this.state.commentsList.length === 0 && /*#__PURE__*/React.createElement("li", {
|
|
220
|
+
className: "comment-vacant"
|
|
221
|
+
}, t('no_comment_yet'))), /*#__PURE__*/React.createElement("div", {
|
|
222
|
+
className: "seafile-comment-footer"
|
|
223
|
+
}, participants && window.showParticipants && /*#__PURE__*/React.createElement(ParticipantsList, {
|
|
224
|
+
openDialogs: this.props.openDialogs,
|
|
225
|
+
participants: participants,
|
|
226
|
+
t: this.props.t
|
|
227
|
+
}), window.showParticipants ? /*#__PURE__*/React.createElement(MentionsInput, {
|
|
228
|
+
value: this.state.comment,
|
|
229
|
+
onChange: this.handleCommentChange,
|
|
230
|
+
placeholder: t('add_a_comment'),
|
|
231
|
+
style: defaultStyle
|
|
232
|
+
}, /*#__PURE__*/React.createElement(Mention, {
|
|
233
|
+
trigger: "@",
|
|
234
|
+
displayTransform: function displayTransform(username, display) {
|
|
235
|
+
return "@".concat(display);
|
|
236
|
+
},
|
|
237
|
+
data: this.state.relatedUsers,
|
|
238
|
+
renderSuggestion: this.renderUserSuggestion,
|
|
239
|
+
onAdd: function onAdd(id, display) {
|
|
240
|
+
_this2.addParticipant(id);
|
|
241
|
+
},
|
|
242
|
+
appendSpaceOnAdd: true
|
|
243
|
+
})) : /*#__PURE__*/React.createElement("textarea", {
|
|
244
|
+
className: "add-comment-input",
|
|
245
|
+
onChange: this.handleCommentChange,
|
|
246
|
+
value: this.state.comment,
|
|
247
|
+
placeholder: t('add_a_comment'),
|
|
248
|
+
clos: "100",
|
|
249
|
+
rows: "3",
|
|
250
|
+
warp: "virtual"
|
|
251
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
252
|
+
className: "submit-comment",
|
|
253
|
+
color: "primary",
|
|
254
|
+
size: "sm",
|
|
255
|
+
onClick: this.onSubmit
|
|
256
|
+
}, t('submit'))));
|
|
257
|
+
}
|
|
258
|
+
}]);
|
|
259
|
+
|
|
260
|
+
return CommentPanel;
|
|
261
|
+
}(React.Component);
|
|
262
|
+
|
|
263
|
+
var CommentItem = /*#__PURE__*/function (_React$Component2) {
|
|
264
|
+
_inherits(CommentItem, _React$Component2);
|
|
265
|
+
|
|
266
|
+
var _super2 = _createSuper(CommentItem);
|
|
267
|
+
|
|
268
|
+
function CommentItem(props) {
|
|
269
|
+
var _this3;
|
|
270
|
+
|
|
271
|
+
_classCallCheck(this, CommentItem);
|
|
272
|
+
|
|
273
|
+
_this3 = _super2.call(this, props);
|
|
274
|
+
|
|
275
|
+
_this3.toggleDropDownMenu = function () {
|
|
276
|
+
_this3.setState({
|
|
277
|
+
dropdownOpen: !_this3.state.dropdownOpen
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
_this3.convertComment = function (item) {
|
|
282
|
+
processor.process(item.comment).then(function (result) {
|
|
283
|
+
var html = String(result);
|
|
284
|
+
|
|
285
|
+
_this3.setState({
|
|
286
|
+
html: html
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
if (item.detail) {
|
|
291
|
+
var detail = JSON.parse(item.detail);
|
|
292
|
+
processor.process(detail.quote).then(function (result) {
|
|
293
|
+
var quote = String(result);
|
|
294
|
+
|
|
295
|
+
_this3.setState({
|
|
296
|
+
quote: quote,
|
|
297
|
+
position: detail.position
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
_this3.toggleEditComment = function () {
|
|
304
|
+
_this3.setState({
|
|
305
|
+
editable: !_this3.state.editable
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
_this3.updateComment = function (event) {
|
|
310
|
+
var newComment = _this3.state.newComment;
|
|
311
|
+
|
|
312
|
+
if (_this3.props.item.comment !== newComment) {
|
|
313
|
+
_this3.props.editComment(event.target.id, newComment);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
_this3.toggleEditComment();
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
_this3.handleCommentChange = function (event) {
|
|
320
|
+
_this3.setState({
|
|
321
|
+
newComment: event.target.value
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
_this3.state = {
|
|
326
|
+
dropdownOpen: false,
|
|
327
|
+
html: '',
|
|
328
|
+
newComment: _this3.props.item.comment,
|
|
329
|
+
editable: false,
|
|
330
|
+
quote: '',
|
|
331
|
+
position: null
|
|
332
|
+
};
|
|
333
|
+
return _this3;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
_createClass(CommentItem, [{
|
|
337
|
+
key: "componentWillMount",
|
|
338
|
+
value: function componentWillMount() {
|
|
339
|
+
this.convertComment(this.props.item);
|
|
340
|
+
}
|
|
341
|
+
}, {
|
|
342
|
+
key: "componentWillReceiveProps",
|
|
343
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
344
|
+
this.convertComment(nextProps.item);
|
|
345
|
+
}
|
|
346
|
+
}, {
|
|
347
|
+
key: "render",
|
|
348
|
+
value: function render() {
|
|
349
|
+
var _this$props = this.props,
|
|
350
|
+
item = _this$props.item,
|
|
351
|
+
t = _this$props.t,
|
|
352
|
+
editorApi = _this$props.editorApi;
|
|
353
|
+
|
|
354
|
+
if (item.resolved && !this.props.showResolvedComment) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (this.state.editable) {
|
|
359
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
360
|
+
className: "seafile-comment-item",
|
|
361
|
+
id: item.id
|
|
362
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
363
|
+
className: "seafile-comment-info"
|
|
364
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
365
|
+
className: "avatar",
|
|
366
|
+
src: item.avatar_url,
|
|
367
|
+
alt: ""
|
|
368
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
369
|
+
className: "reviewer-info"
|
|
370
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
371
|
+
className: "reviewer-name ellipsis"
|
|
372
|
+
}, item.user_name), /*#__PURE__*/React.createElement("div", {
|
|
373
|
+
className: "review-time"
|
|
374
|
+
}, this.props.time))), /*#__PURE__*/React.createElement("div", {
|
|
375
|
+
className: "seafile-edit-comment"
|
|
376
|
+
}, /*#__PURE__*/React.createElement("textarea", {
|
|
377
|
+
className: "edit-comment-input",
|
|
378
|
+
value: this.state.newComment,
|
|
379
|
+
onChange: this.handleCommentChange,
|
|
380
|
+
clos: "100",
|
|
381
|
+
rows: "3",
|
|
382
|
+
warp: "virtual"
|
|
383
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
384
|
+
className: "comment-btn",
|
|
385
|
+
color: "primary",
|
|
386
|
+
size: "sm",
|
|
387
|
+
onClick: this.updateComment,
|
|
388
|
+
id: item.id
|
|
389
|
+
}, t('Update')), ' ', /*#__PURE__*/React.createElement(Button, {
|
|
390
|
+
className: "comment-btn",
|
|
391
|
+
color: "secondary",
|
|
392
|
+
size: "sm",
|
|
393
|
+
onClick: this.toggleEditComment
|
|
394
|
+
}, t('cancel'))));
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
398
|
+
className: item.resolved ? 'seafile-comment-item seafile-comment-item-resolved' : 'seafile-comment-item',
|
|
399
|
+
id: item.id
|
|
400
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
401
|
+
className: "seafile-comment-info"
|
|
402
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
403
|
+
className: "avatar",
|
|
404
|
+
src: item.avatar_url,
|
|
405
|
+
alt: ""
|
|
406
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
407
|
+
className: "reviewer-info"
|
|
408
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
409
|
+
className: "reviewer-name ellipsis"
|
|
410
|
+
}, item.user_name), /*#__PURE__*/React.createElement("div", {
|
|
411
|
+
className: "review-time"
|
|
412
|
+
}, this.props.time)), /*#__PURE__*/React.createElement(Dropdown, {
|
|
413
|
+
isOpen: this.state.dropdownOpen,
|
|
414
|
+
size: "sm",
|
|
415
|
+
className: "seafile-comment-dropdown",
|
|
416
|
+
toggle: this.toggleDropDownMenu
|
|
417
|
+
}, /*#__PURE__*/React.createElement(DropdownToggle, {
|
|
418
|
+
className: "seafile-comment-dropdown-btn"
|
|
419
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
420
|
+
className: "iconfont icon-ellipsis-v"
|
|
421
|
+
})), /*#__PURE__*/React.createElement(DropdownMenu, null, item.user_email === editorApi.userName && /*#__PURE__*/React.createElement(DropdownItem, {
|
|
422
|
+
onClick: this.props.deleteComment,
|
|
423
|
+
className: "delete-comment",
|
|
424
|
+
id: item.id
|
|
425
|
+
}, t('delete')), item.user_email === editorApi.userName && /*#__PURE__*/React.createElement(DropdownItem, {
|
|
426
|
+
onClick: this.toggleEditComment,
|
|
427
|
+
className: "edit-comment",
|
|
428
|
+
id: item.id
|
|
429
|
+
}, t('edit')), !item.resolved && /*#__PURE__*/React.createElement(DropdownItem, {
|
|
430
|
+
onClick: this.props.resolveComment,
|
|
431
|
+
className: "seafile-comment-resolved",
|
|
432
|
+
id: item.id
|
|
433
|
+
}, t('Mark_as_Resolved'))))), item.detail && /*#__PURE__*/React.createElement("blockquote", {
|
|
434
|
+
className: "seafile-comment-content"
|
|
435
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
436
|
+
onClick: this.props.scrollToQuote.bind(this, this.state.position),
|
|
437
|
+
dangerouslySetInnerHTML: {
|
|
438
|
+
__html: this.state.quote
|
|
439
|
+
}
|
|
440
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
441
|
+
className: "seafile-comment-content",
|
|
442
|
+
dangerouslySetInnerHTML: {
|
|
443
|
+
__html: this.state.html
|
|
444
|
+
}
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
}]);
|
|
448
|
+
|
|
449
|
+
return CommentItem;
|
|
450
|
+
}(React.Component);
|
|
451
|
+
|
|
452
|
+
export default CommentPanel;
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
|
|
8
|
+
var ContextMenu = /*#__PURE__*/function (_React$Component) {
|
|
9
|
+
_inherits(ContextMenu, _React$Component);
|
|
10
|
+
|
|
11
|
+
var _super = _createSuper(ContextMenu);
|
|
12
|
+
|
|
13
|
+
function ContextMenu(props) {
|
|
14
|
+
var _this;
|
|
15
|
+
|
|
16
|
+
_classCallCheck(this, ContextMenu);
|
|
17
|
+
|
|
18
|
+
_this = _super.call(this, props);
|
|
19
|
+
|
|
20
|
+
_this.setMenuPosition = function () {
|
|
21
|
+
var menuHeight = _this.menu.offsetHeight; // get height of context menu when the menu is drawing completed in this page
|
|
22
|
+
|
|
23
|
+
if (menuHeight === 0) {
|
|
24
|
+
requestAnimationFrame(_this.setMenuPosition);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var top = 0;
|
|
28
|
+
|
|
29
|
+
if (_this.position.top + menuHeight > document.body.clientHeight) {
|
|
30
|
+
top = document.body.clientHeight - menuHeight - 5;
|
|
31
|
+
} else {
|
|
32
|
+
top = _this.position.top;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var left = _this.position.left + 3;
|
|
36
|
+
|
|
37
|
+
_this.setState({
|
|
38
|
+
contextStyle: {
|
|
39
|
+
top: top,
|
|
40
|
+
left: left,
|
|
41
|
+
zIndex: '1051',
|
|
42
|
+
display: 'block'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
_this.tableUtils = props.tableUtils;
|
|
48
|
+
_this.state = {
|
|
49
|
+
contextStyle: {}
|
|
50
|
+
};
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_createClass(ContextMenu, [{
|
|
55
|
+
key: "componentDidMount",
|
|
56
|
+
value: function componentDidMount() {
|
|
57
|
+
this.position = this.props.contextMenuPosition;
|
|
58
|
+
this.setMenuPosition();
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "componentWillUnmount",
|
|
62
|
+
value: function componentWillUnmount() {
|
|
63
|
+
this.menu = null;
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "render",
|
|
67
|
+
value: function render() {
|
|
68
|
+
var _this2 = this;
|
|
69
|
+
|
|
70
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
role: 'menu',
|
|
72
|
+
style: this.state.contextStyle,
|
|
73
|
+
ref: function ref(_ref) {
|
|
74
|
+
return _this2.menu = _ref;
|
|
75
|
+
},
|
|
76
|
+
className: 'seafile-contextmenu dropdown-menu'
|
|
77
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
78
|
+
onMouseDown: function onMouseDown(event) {
|
|
79
|
+
return _this2.tableUtils.insertRow('before');
|
|
80
|
+
},
|
|
81
|
+
className: 'seafile-contextmenu-item dropdown-item'
|
|
82
|
+
}, this.props.t('Insert_Row_Before')), /*#__PURE__*/React.createElement("button", {
|
|
83
|
+
onMouseDown: function onMouseDown(event) {
|
|
84
|
+
return _this2.tableUtils.insertRow('after');
|
|
85
|
+
},
|
|
86
|
+
className: 'seafile-contextmenu-item dropdown-item'
|
|
87
|
+
}, this.props.t('Insert_Row_After')), /*#__PURE__*/React.createElement("button", {
|
|
88
|
+
onMouseDown: function onMouseDown(event) {
|
|
89
|
+
return _this2.tableUtils.insertColumn('before');
|
|
90
|
+
},
|
|
91
|
+
className: 'seafile-contextmenu-item dropdown-item'
|
|
92
|
+
}, this.props.t('Insert_Column_Before')), /*#__PURE__*/React.createElement("button", {
|
|
93
|
+
onMouseDown: function onMouseDown(event) {
|
|
94
|
+
return _this2.tableUtils.insertColumn('after');
|
|
95
|
+
},
|
|
96
|
+
className: 'seafile-contextmenu-item dropdown-item'
|
|
97
|
+
}, this.props.t('Insert_Column_After')), /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: 'seafile-divider dropdown-divider'
|
|
99
|
+
}), /*#__PURE__*/React.createElement("button", {
|
|
100
|
+
onMouseDown: this.tableUtils.removeRow,
|
|
101
|
+
className: 'seafile-contextmenu-item dropdown-item'
|
|
102
|
+
}, this.props.t('Remove_Row')), /*#__PURE__*/React.createElement("button", {
|
|
103
|
+
onMouseDown: this.tableUtils.removeColumn,
|
|
104
|
+
className: 'seafile-contextmenu-item dropdown-item'
|
|
105
|
+
}, this.props.t('Remove_Column')));
|
|
106
|
+
}
|
|
107
|
+
}]);
|
|
108
|
+
|
|
109
|
+
return ContextMenu;
|
|
110
|
+
}(React.Component);
|
|
111
|
+
|
|
112
|
+
export default withTranslation('seafile-editor')(ContextMenu);
|
|
@@ -0,0 +1,119 @@
|
|
|
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 moment from 'moment';
|
|
7
|
+
import ParticipantsList from './participants-list';
|
|
8
|
+
import '../css/richeditor/detail-list-view.css';
|
|
9
|
+
|
|
10
|
+
var DetailListView = /*#__PURE__*/function (_React$Component) {
|
|
11
|
+
_inherits(DetailListView, _React$Component);
|
|
12
|
+
|
|
13
|
+
var _super = _createSuper(DetailListView);
|
|
14
|
+
|
|
15
|
+
function DetailListView() {
|
|
16
|
+
var _this;
|
|
17
|
+
|
|
18
|
+
_classCallCheck(this, DetailListView);
|
|
19
|
+
|
|
20
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
+
args[_key] = arguments[_key];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
|
+
|
|
26
|
+
_this.onEditFileTagToggle = function () {
|
|
27
|
+
_this.props.openDialogs && _this.props.openDialogs('file_tags');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
_this.onListRelatedFileToggle = function () {
|
|
31
|
+
_this.props.openDialogs && _this.props.openDialogs('related_files');
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_this.bytesToSize = function (bytes) {
|
|
35
|
+
if (bytes < 0) return '--';
|
|
36
|
+
var sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
|
37
|
+
|
|
38
|
+
if (bytes === 0) {
|
|
39
|
+
return bytes + ' ' + sizes[0];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1000)), 10);
|
|
43
|
+
|
|
44
|
+
if (i === 0) {
|
|
45
|
+
return bytes + ' ' + sizes[i];
|
|
46
|
+
} else {
|
|
47
|
+
return (bytes / Math.pow(1000, i)).toFixed(1) + ' ' + sizes[i];
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_createClass(DetailListView, [{
|
|
55
|
+
key: "render",
|
|
56
|
+
value: function render() {
|
|
57
|
+
var _this$props = this.props,
|
|
58
|
+
fileTagList = _this$props.fileTagList,
|
|
59
|
+
relatedFiles = _this$props.relatedFiles,
|
|
60
|
+
fileInfo = _this$props.fileInfo;
|
|
61
|
+
var _this$props$editorApi = this.props.editorApi,
|
|
62
|
+
filePath = _this$props$editorApi.filePath,
|
|
63
|
+
serviceUrl = _this$props$editorApi.serviceUrl;
|
|
64
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
className: "dirent-table-container"
|
|
66
|
+
}, /*#__PURE__*/React.createElement("table", {
|
|
67
|
+
className: "table-thead-hidden"
|
|
68
|
+
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
69
|
+
width: "40%"
|
|
70
|
+
}), /*#__PURE__*/React.createElement("th", {
|
|
71
|
+
width: "60%"
|
|
72
|
+
}))), /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, this.props.t('Size')), /*#__PURE__*/React.createElement("td", null, this.bytesToSize(fileInfo.size))), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, this.props.t('Location')), /*#__PURE__*/React.createElement("td", null, filePath)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, this.props.t('Last_Update')), /*#__PURE__*/React.createElement("td", null, moment(fileInfo.last_modified).fromNow())), /*#__PURE__*/React.createElement("tr", {
|
|
73
|
+
className: "file-tag-container"
|
|
74
|
+
}, /*#__PURE__*/React.createElement("th", null, this.props.t('Tags')), /*#__PURE__*/React.createElement("td", null, fileTagList.length > 0 && /*#__PURE__*/React.createElement("ul", {
|
|
75
|
+
className: "file-tag-list"
|
|
76
|
+
}, fileTagList.map(function (fileTag) {
|
|
77
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
78
|
+
key: fileTag.id,
|
|
79
|
+
className: "file-tag-item"
|
|
80
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: "file-tag",
|
|
82
|
+
style: {
|
|
83
|
+
backgroundColor: fileTag.tag_color
|
|
84
|
+
}
|
|
85
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
86
|
+
className: "tag-name",
|
|
87
|
+
title: fileTag.tag_name
|
|
88
|
+
}, fileTag.tag_name));
|
|
89
|
+
})), /*#__PURE__*/React.createElement("i", {
|
|
90
|
+
className: "iconfont icon-pencil attr-action-icon",
|
|
91
|
+
onClick: this.onEditFileTagToggle
|
|
92
|
+
}))), /*#__PURE__*/React.createElement("tr", {
|
|
93
|
+
className: "file-related-files"
|
|
94
|
+
}, /*#__PURE__*/React.createElement("th", null, this.props.t('Related_Files')), /*#__PURE__*/React.createElement("td", null, relatedFiles.length > 0 && /*#__PURE__*/React.createElement("ul", null, relatedFiles.map(function (relatedFile, index) {
|
|
95
|
+
var href = serviceUrl + '/lib/' + relatedFile.repo_id + '/file' + encodeURIComponent(relatedFile.path);
|
|
96
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
97
|
+
key: index
|
|
98
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
99
|
+
href: href,
|
|
100
|
+
rel: "noopener noreferrer",
|
|
101
|
+
target: "_blank"
|
|
102
|
+
}, relatedFile.name));
|
|
103
|
+
})), /*#__PURE__*/React.createElement("i", {
|
|
104
|
+
className: "iconfont icon-pencil attr-action-icon",
|
|
105
|
+
onClick: this.onListRelatedFileToggle
|
|
106
|
+
}))), this.props.participants && window.showParticipants && /*#__PURE__*/React.createElement("tr", {
|
|
107
|
+
className: "file-participants"
|
|
108
|
+
}, /*#__PURE__*/React.createElement("th", null, this.props.t('Participants')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement(ParticipantsList, {
|
|
109
|
+
openDialogs: this.props.openDialogs,
|
|
110
|
+
participants: this.props.participants,
|
|
111
|
+
t: this.props.t
|
|
112
|
+
}))))));
|
|
113
|
+
}
|
|
114
|
+
}]);
|
|
115
|
+
|
|
116
|
+
return DetailListView;
|
|
117
|
+
}(React.Component);
|
|
118
|
+
|
|
119
|
+
export default DetailListView;
|