@seafile/sdoc-editor 0.2.21 → 0.2.23-beta

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.
Files changed (30) hide show
  1. package/dist/api/seafile-api.js +55 -0
  2. package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +2 -2
  3. package/dist/basic-sdk/extension/plugins/image/render-elem.js +14 -32
  4. package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +23 -0
  5. package/dist/components/doc-info/index.js +3 -1
  6. package/dist/components/doc-operations/comments-operation/index.js +1 -1
  7. package/dist/components/doc-operations/index.js +5 -2
  8. package/dist/components/doc-operations/revision-operations/index.js +8 -7
  9. package/dist/components/doc-operations/revision-operations/revisions/revisions-dialog/index.js +3 -2
  10. package/dist/components/doc-operations/tag-operation/constans.js +2 -0
  11. package/dist/components/doc-operations/tag-operation/index.js +11 -0
  12. package/dist/components/doc-operations/tag-operation/tag-popover/index.css +70 -0
  13. package/dist/components/doc-operations/tag-operation/tag-popover/index.js +251 -0
  14. package/dist/components/doc-operations/tag-operation/utils.js +8 -0
  15. package/dist/context.js +54 -0
  16. package/dist/hooks/use-config.js +2 -0
  17. package/dist/hooks/use-document.js +7 -2
  18. package/dist/layout/layout.js +11 -1
  19. package/dist/pages/simple-editor.js +15 -6
  20. package/package.json +1 -1
  21. package/public/locales/cs/sdoc-editor.json +29 -15
  22. package/public/locales/de/sdoc-editor.json +29 -15
  23. package/public/locales/en/sdoc-editor.json +31 -15
  24. package/public/locales/es/sdoc-editor.json +29 -15
  25. package/public/locales/fr/sdoc-editor.json +29 -15
  26. package/public/locales/it/sdoc-editor.json +29 -15
  27. package/public/locales/ru/sdoc-editor.json +29 -15
  28. package/public/locales/zh_CN/sdoc-editor.json +31 -15
  29. package/public/media/sdoc-editor-font/iconfont.svg +0 -4
  30. package/public/media/sdoc-editor-font.css +0 -8
@@ -187,6 +187,61 @@ var SeafileAPI = /*#__PURE__*/function () {
187
187
  var url = 'api/v2.1/seadoc/related-users/' + docUuid + '/';
188
188
  return this.req.get(url);
189
189
  }
190
+
191
+ // Operate file tags
192
+ }, {
193
+ key: "getFileTagList",
194
+ value: function getFileTagList(docUuid) {
195
+ var url = "/api/v2.1/seadoc/file-tags/".concat(docUuid, "/");
196
+ return this.req.get(url);
197
+ }
198
+ }, {
199
+ key: "addFileTag",
200
+ value: function addFileTag(docUuid, repoTagID) {
201
+ var form = new FormData();
202
+ form.append('repo_tag_id', repoTagID);
203
+ var url = "/api/v2.1/seadoc/file-tags/".concat(docUuid, "/");
204
+ return this._sendPostRequest(url, form);
205
+ }
206
+ }, {
207
+ key: "removeFileTag",
208
+ value: function removeFileTag(docUuid, fileTagID) {
209
+ var url = "/api/v2.1/seadoc/file-tags/".concat(docUuid, "/").concat(fileTagID, "/");
210
+ return this.req.delete(url);
211
+ }
212
+
213
+ // Operate repository tags
214
+ }, {
215
+ key: "getRepoTagList",
216
+ value: function getRepoTagList(docUuid) {
217
+ var url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/");
218
+ return this.req.get(url);
219
+ }
220
+ }, {
221
+ key: "createRepoTag",
222
+ value: function createRepoTag(docUuid, repoTagName, color) {
223
+ var url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/");
224
+ var form = new FormData();
225
+ form.append('name', repoTagName);
226
+ form.append('color', color);
227
+ return this._sendPostRequest(url, form);
228
+ }
229
+ }, {
230
+ key: "removeRepoTag",
231
+ value: function removeRepoTag(docUuid, repoTagId) {
232
+ var url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/").concat(repoTagId, "/");
233
+ return this.req.delete(url);
234
+ }
235
+ }, {
236
+ key: "updateRepoTag",
237
+ value: function updateRepoTag(docUuid, repoTagId, repoTagName, color) {
238
+ var url = "/api/v2.1/seadoc/repo-tags/".concat(docUuid, "/").concat(repoTagId, "/");
239
+ var params = {
240
+ name: repoTagName,
241
+ color: color
242
+ };
243
+ return this.req.put(url, params);
244
+ }
190
245
  }]);
191
246
  return SeafileAPI;
192
247
  }();
@@ -40,7 +40,7 @@
40
40
  .sdoc-editor-container .article .sdoc-image-wrapper {
41
41
  position: relative;
42
42
  display: inline-block;
43
- margin: 0 3px;
43
+ padding: 6px 6px 6px 0;
44
44
  }
45
45
 
46
46
  .sdoc-editor-container .article .sdoc-image-inner {
@@ -51,7 +51,7 @@
51
51
  .sdoc-editor-container .article .sdoc-image-content {
52
52
  display: flex;
53
53
  flex-direction: column;
54
- align-items: start;
54
+ align-items: flex-start;
55
55
  }
56
56
 
57
57
  .sdoc-editor-container .article .sdoc-image-content :first-child {
@@ -1,5 +1,5 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import React, { useState, useCallback, useRef, useEffect } from 'react';
4
4
  import { ReactEditor, useSelected, useReadOnly } from '@seafile/slate-react';
5
5
  import { Transforms } from '@seafile/slate';
@@ -16,6 +16,7 @@ import imagePlaceholder from '../../../assets/images/image-placeholder.png';
16
16
  var Image = function Image(_ref) {
17
17
  var element = _ref.element,
18
18
  editor = _ref.editor,
19
+ style = _ref.style,
19
20
  className = _ref.className,
20
21
  attributes = _ref.attributes,
21
22
  children = _ref.children,
@@ -26,11 +27,11 @@ var Image = function Image(_ref) {
26
27
  align = element.align,
27
28
  _element$border_type = element.border_type,
28
29
  border_type = _element$border_type === void 0 ? IMAGE_BORDER_TYPE[0].type : _element$border_type;
29
- var imageWrapStyle = {
30
+ var imageWrapStyle = _objectSpread(_objectSpread({}, style), {}, {
30
31
  display: display_type === 'Block' ? 'block' : 'inline-block',
31
32
  paddingTop: display_type === 'Block' ? '8px' : '',
32
33
  textAlign: display_type === 'Block' ? align : ''
33
- };
34
+ });
34
35
  var imageStyle = {
35
36
  border: IMAGE_BORDER_TYPE.find(function (item) {
36
37
  return item.type === border_type;
@@ -213,7 +214,9 @@ var Image = function Image(_ref) {
213
214
  }, [data, editor, element]);
214
215
  return /*#__PURE__*/React.createElement(React.Fragment, null, isShowImagePlaceholder && /*#__PURE__*/React.createElement("span", Object.assign({
215
216
  className: classNames('sdoc-image-wrapper', className)
216
- }, attributes), /*#__PURE__*/React.createElement("img", {
217
+ }, attributes, {
218
+ style: imageWrapStyle
219
+ }), /*#__PURE__*/React.createElement("img", {
217
220
  ref: imageRef,
218
221
  src: imagePlaceholder,
219
222
  style: getImageStyle(),
@@ -250,7 +253,7 @@ var Image = function Image(_ref) {
250
253
  }, /*#__PURE__*/React.createElement("span", null, t('Width'), ':', parseInt(movingWidth || imageRef.current.clientWidth)), /*#__PURE__*/React.createElement("span", null, "\xA0\xA0"), /*#__PURE__*/React.createElement("span", null, t('Height'), ':', imageRef.current.clientHeight))), display_type === 'Block' && (isShowCaption || (data === null || data === void 0 ? void 0 : data.caption)) && /*#__PURE__*/React.createElement("input", {
251
254
  className: "sdoc-image-caption-input-wrapper",
252
255
  style: {
253
- width: (data === null || data === void 0 ? void 0 : data.width) || '120px'
256
+ width: (data === null || data === void 0 ? void 0 : data.width) || imageRef.current.clientWidth
254
257
  },
255
258
  placeholder: t('Insert_caption'),
256
259
  value: caption,
@@ -281,36 +284,15 @@ function renderImage(props, editor) {
281
284
  // decorate diff-viewer
282
285
  var element = props.element,
283
286
  leaf = props.leaf;
284
- if (element.ADD || element.DELETE) {
285
- var style = element.ADD ? ADDED_STYLE : DELETED_STYLE;
286
- return /*#__PURE__*/React.createElement("span", {
287
- className: "d-inline-block p-1",
288
- style: {
289
- backgroundColor: style.computed_background_color,
290
- width: 'fit-content',
291
- height: 'fit-content'
292
- }
293
- }, /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
294
- className: classNames(props.className || '', 'm-0'),
295
- editor: editor,
296
- isSelected: isSelected
297
- })));
298
- }
287
+ var style = _objectSpread({}, props.style);
299
288
  if (leaf && leaf.computed_background_color) {
300
- return /*#__PURE__*/React.createElement("span", {
301
- className: "d-inline-block p-1",
302
- style: {
303
- backgroundColor: leaf.computed_background_color,
304
- width: 'fit-content',
305
- height: 'fit-content'
306
- }
307
- }, /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
308
- className: classNames(props.className || '', 'm-0'),
309
- editor: editor,
310
- isSelected: isSelected
311
- })));
289
+ style['backgroundColor'] = leaf.computed_background_color;
290
+ }
291
+ if (element.ADD || element.DELETE) {
292
+ style = Object.assign({}, style, element.ADD ? ADDED_STYLE : DELETED_STYLE);
312
293
  }
313
294
  return /*#__PURE__*/React.createElement(SdocImage, Object.assign({}, props, {
295
+ style: style,
314
296
  editor: editor,
315
297
  isSelected: isSelected
316
298
  }));
@@ -2,6 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import React, { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { withTranslation } from 'react-i18next';
4
4
  import { useSlateStatic } from '@seafile/slate-react';
5
+ import copy from 'copy-to-clipboard';
6
+ import context from '../../../../context';
5
7
  import EventBus from '../../../utils/event-bus';
6
8
  import { ElementPopover } from '../../commons';
7
9
  import InsertBelowMenu from './insert-below-menu';
@@ -9,6 +11,8 @@ import InsertBlockMenu from './insert-block-menu';
9
11
  import { onCopyNode, onDeleteNode, isNotSupportTransform } from './helpers';
10
12
  import TransformMenus from './transform-menus';
11
13
  import DropdownMenuItem from '../../commons/dropdown-menu-item';
14
+ import toaster from '../../../../components/toast';
15
+ import { HEADER1, HEADER2, HEADER3 } from '../../constants';
12
16
  import './side-menu.css';
13
17
  var SideMenu = function SideMenu(_ref) {
14
18
  var slateNode = _ref.slateNode,
@@ -41,6 +45,17 @@ var SideMenu = function SideMenu(_ref) {
41
45
  onDeleteNode(editor, slateNode);
42
46
  onReset();
43
47
  }, [editor, onReset, slateNode]);
48
+ var onCopyHeaderLink = useCallback(function () {
49
+ var serviceUrl = context.getSetting('serviceUrl');
50
+ var sdocUuid = context.getSetting('docUuid');
51
+ var href = serviceUrl + "/smart-link/".concat(sdocUuid, "/#").concat(slateNode.id);
52
+ copy(href);
53
+ toaster.success(t('Copied'), {
54
+ hasCloseButton: false,
55
+ duration: 2
56
+ });
57
+ onReset();
58
+ }, [onReset, slateNode.id, t]);
44
59
  useEffect(function () {
45
60
  var top = menuPosition.top;
46
61
  if (sideMenuRef.current) {
@@ -87,6 +102,14 @@ var SideMenu = function SideMenu(_ref) {
87
102
  slateNode: slateNode
88
103
  })), /*#__PURE__*/React.createElement("div", {
89
104
  className: "sdoc-dropdown-menu-divider"
105
+ }), [HEADER1, HEADER2, HEADER3].includes(slateNode === null || slateNode === void 0 ? void 0 : slateNode.type) && /*#__PURE__*/React.createElement(DropdownMenuItem, {
106
+ menuConfig: {
107
+ text: 'Copy_link_of_section',
108
+ iconClass: 'sdocfont sdoc-link'
109
+ },
110
+ onClick: onCopyHeaderLink
111
+ }), /*#__PURE__*/React.createElement("div", {
112
+ className: "sdoc-dropdown-menu-divider"
90
113
  }), /*#__PURE__*/React.createElement(DropdownMenuItem, {
91
114
  menuConfig: {
92
115
  text: 'Copy',
@@ -7,12 +7,15 @@ import { EXTERNAL_EVENT } from '../../constants';
7
7
  import { DateUtils } from '../../utils';
8
8
  import DraftDropdown from '../draft-dropdown';
9
9
  import RevisionAvatar from '../../assets/images/revision-avatar.png';
10
+ import { useDocument } from '../../hooks';
10
11
  import './index.css';
11
12
  var DocInfo = function DocInfo(_ref) {
12
13
  var t = _ref.t,
13
14
  isStarred = _ref.isStarred,
14
15
  isDraft = _ref.isDraft,
15
16
  isEditMode = _ref.isEditMode;
17
+ var _useDocument = useDocument(),
18
+ isPublished = _useDocument.isPublished;
16
19
  var onInternalLinkClick = useCallback(function () {
17
20
  var eventBus = EventBus.getInstance();
18
21
  eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
@@ -50,7 +53,6 @@ var DocInfo = function DocInfo(_ref) {
50
53
  var revisionCreatedAt = context.getSetting('revisionCreatedAt');
51
54
  var oldDocName = context.getSetting('originFilename');
52
55
  var revisionId = context.getSetting('revisionId');
53
- var isPublished = context.getSetting('isPublished');
54
56
  return /*#__PURE__*/React.createElement("div", {
55
57
  className: "sdoc-revision-info doc-info"
56
58
  }, /*#__PURE__*/React.createElement("div", {
@@ -11,6 +11,6 @@ export default function CommentsOperation() {
11
11
  className: "op-item",
12
12
  onClick: onCommentsToggle
13
13
  }, /*#__PURE__*/React.createElement("i", {
14
- className: "sdocfont sdoc-comments mr-1"
14
+ className: "sdocfont sdoc-comments"
15
15
  }));
16
16
  }
@@ -7,7 +7,9 @@ import CollaboratorsOperation from './collaborators-operation';
7
7
  import MoreOperations from './more-operations';
8
8
  import CommentsOperation from './comments-operation';
9
9
  import ShareOperation from './share-operation';
10
+ import TagOperation from './tag-operation';
10
11
  import { isMobile } from '../../utils';
12
+ import { useDocument } from '../../hooks';
11
13
  import './style.css';
12
14
  var DocOperations = function DocOperations(_ref) {
13
15
  var isShowChanges = _ref.isShowChanges,
@@ -15,7 +17,8 @@ var DocOperations = function DocOperations(_ref) {
15
17
  handleViewChangesToggle = _ref.handleViewChangesToggle,
16
18
  handleRevisionPublished = _ref.handleRevisionPublished;
17
19
  var isSdocRevision = context.getSetting('isSdocRevision');
18
- var isPublished = context.getSetting('isPublished');
20
+ var _useDocument = useDocument(),
21
+ isPublished = _useDocument.isPublished;
19
22
  if (isMobile) {
20
23
  return /*#__PURE__*/React.createElement("div", {
21
24
  className: "doc-ops"
@@ -28,6 +31,6 @@ var DocOperations = function DocOperations(_ref) {
28
31
  changes: changes,
29
32
  handleViewChangesToggle: handleViewChangesToggle,
30
33
  handleRevisionPublished: handleRevisionPublished
31
- }), !isPublished && /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), /*#__PURE__*/React.createElement(HistoryOperation, null), !isPublished && /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
34
+ }), !isPublished && /*#__PURE__*/React.createElement(TagOperation, null), !isPublished && /*#__PURE__*/React.createElement(CommentsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(ShareOperation, null), /*#__PURE__*/React.createElement(HistoryOperation, null), !isPublished && /*#__PURE__*/React.createElement(CollaboratorsOperation, null), !isSdocRevision && /*#__PURE__*/React.createElement(MoreOperations, null));
32
35
  };
33
36
  export default withTranslation('sdoc-editor')(DocOperations);
@@ -19,7 +19,6 @@ var RevisionOperations = function RevisionOperations(_ref) {
19
19
  handleViewChangesToggle = _ref.handleViewChangesToggle,
20
20
  handleRevisionPublished = _ref.handleRevisionPublished;
21
21
  var isSdocRevision = context.getSetting('isSdocRevision');
22
- var isPublished = context.getSetting('isPublished');
23
22
  var _useTranslation = useTranslation(),
24
23
  t = _useTranslation.t;
25
24
  var _useState = useState(false),
@@ -34,16 +33,20 @@ var RevisionOperations = function RevisionOperations(_ref) {
34
33
  _useState6 = _slicedToArray(_useState5, 2),
35
34
  mergeValue = _useState6[0],
36
35
  setMergeValue = _useState6[1];
36
+ var _useDocument = useDocument(),
37
+ loadDocument = _useDocument.loadDocument,
38
+ isPublished = _useDocument.isPublished,
39
+ setPublished = _useDocument.setPublished;
37
40
  var onDocumentReplaced = useCallback(function () {
38
41
  if (isShowTip) return;
39
42
  setTipType(TIP_TYPE.HAS_BEEN_REPLACED);
40
43
  setShowTip(true);
41
44
  }, [isShowTip]);
42
45
  var hasPublishRevision = useCallback(function () {
43
- if (isShowTip) return;
44
- setTipType(TIP_TYPE.HAS_BEEN_PUBLISHED);
45
- setShowTip(true);
46
- }, [isShowTip]);
46
+ if (isPublished) return;
47
+ setPublished(true);
48
+ toaster.success(t('Revision published'));
49
+ }, [isPublished, setPublished, t]);
47
50
  var onDocumentRemoved = useCallback(function () {
48
51
  if (isShowTip) return;
49
52
  setTipType(TIP_TYPE.HAS_BEEN_REMOVED);
@@ -73,8 +76,6 @@ var RevisionOperations = function RevisionOperations(_ref) {
73
76
 
74
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
75
78
  }, []);
76
- var _useDocument = useDocument(),
77
- loadDocument = _useDocument.loadDocument;
78
79
 
79
80
  // solve show change view in revision editor
80
81
  var onViewChangesToggle = useCallback(function (isShowChanges) {
@@ -92,7 +92,8 @@ var RevisionsDialog = function RevisionsDialog(_ref) {
92
92
  var openRevision = useCallback(function (event, revisionId) {
93
93
  eventStopPropagation(event);
94
94
  if (event.target.className.includes('sdoc-revision-operation-toggle')) return;
95
- window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(revisionId, "/");
95
+ var url = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(revisionId, "/");
96
+ window.open(url, '_blank');
96
97
 
97
98
  // eslint-disable-next-line react-hooks/exhaustive-deps
98
99
  }, []);
@@ -251,7 +252,7 @@ var RevisionsDialog = function RevisionsDialog(_ref) {
251
252
  onClose: closeDeleteTipDialog,
252
253
  zIndex: 1071
253
254
  }, t(TIP_CONTENT[TIP_TYPE.DELETE_REVISION], {
254
- content: "".concat(t('Revision'), " ").concat(operatingRevisionId)
255
+ content: "".concat(t('revision'), " ").concat(operatingRevisionId)
255
256
  })));
256
257
  };
257
258
  export default RevisionsDialog;
@@ -0,0 +1,2 @@
1
+ var TAG_COLORS = ['#FBD44A', '#EAA775', '#F4667C', '#DC82D2', '#9860E5', '#9F8CF1', '#59CB74', '#ADDF84', '#89D2EA', '#4ECCCB', '#46A1FD', '#C2C2C2'];
2
+ export { TAG_COLORS };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import TagPopover from './tag-popover';
3
+ var TagOperation = function TagOperation() {
4
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
5
+ className: "op-item tag-operation-icon",
6
+ id: "tag-operation-icon-container"
7
+ }, /*#__PURE__*/React.createElement("i", {
8
+ className: "sdocfont sdoc-tag"
9
+ })), /*#__PURE__*/React.createElement(TagPopover, null));
10
+ };
11
+ export default TagOperation;
@@ -0,0 +1,70 @@
1
+ .sdoc-tag-popover {
2
+ padding-bottom: 0;
3
+ width: 230px;
4
+ }
5
+
6
+ .sdoc-popover-container .sdoc-tag-search-input {
7
+ margin-bottom: 10px;
8
+ }
9
+
10
+ .sdoc-popover-container .sdoc-tag-list-container {
11
+ max-height: 180px;
12
+ overflow-y: auto;
13
+ }
14
+
15
+ .sdoc-tag-item {
16
+ display: flex;
17
+ justify-content: space-between;
18
+ align-items: center;
19
+ padding: 3px 10px;
20
+ width: 100%;
21
+ height: 30px;
22
+ cursor: pointer;
23
+ }
24
+
25
+ .sdoc-tag-item:hover {
26
+ background-color: #eee;
27
+ }
28
+
29
+ .sdoc-tag-item .sdoc-tag-badge-container {
30
+ display: flex;
31
+ align-items: center;
32
+ width: 100%;
33
+ height: 100%;
34
+ overflow: hidden;
35
+ text-overflow: ellipsis;
36
+ white-space: nowrap;
37
+ }
38
+
39
+ .sdoc-tag-item .sdoc-tag-badge {
40
+ margin-right: 10px;
41
+ text-overflow: ellipsis;
42
+ overflow: hidden;
43
+ font-size: 13px;
44
+ }
45
+
46
+ .sdoc-tag-item .sdoc-tag-added-mark {
47
+ width: 18px;
48
+ }
49
+
50
+ .sdoc-create-tag {
51
+ padding: 8px 10px;
52
+ border-top: 1px solid #eee;
53
+ border-bottom: none;
54
+ overflow: hidden;
55
+ text-overflow: ellipsis;
56
+ white-space: nowrap;
57
+ background-color: #fff;
58
+ font-weight: normal;
59
+ cursor: pointer;
60
+ }
61
+
62
+ .sdoc-create-tag:hover {
63
+ background-color: #f5f5f5;
64
+ }
65
+
66
+ .sdoc-create-tag .add-icon {
67
+ margin-right: 6px;
68
+ font-size: 13px;
69
+ font-weight: 600;
70
+ }