@seafile/sdoc-editor 0.2.24-beta1 → 0.2.24-beta2

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.
@@ -8,15 +8,14 @@ import { DateUtils } from '../../utils';
8
8
  import DraftDropdown from '../draft-dropdown';
9
9
  import RevisionAvatar from '../../assets/images/revision-avatar.png';
10
10
  import FileTagQuickView from '../doc-operations/tag-operation/file-tag-quick-view';
11
- import { useConfig } from '../../hooks';
12
11
  import './index.css';
13
12
  var DocInfo = function DocInfo(_ref) {
14
13
  var t = _ref.t,
15
14
  isStarred = _ref.isStarred,
16
15
  isDraft = _ref.isDraft,
17
- isEditMode = _ref.isEditMode;
18
- var _useConfig = useConfig(),
19
- isPublished = _useConfig.isPublished;
16
+ isEditMode = _ref.isEditMode,
17
+ _ref$isPublished = _ref.isPublished,
18
+ isPublished = _ref$isPublished === void 0 ? false : _ref$isPublished;
20
19
  var onInternalLinkClick = useCallback(function () {
21
20
  var eventBus = EventBus.getInstance();
22
21
  eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
@@ -10,16 +10,15 @@ import ShareOperation from './share-operation';
10
10
  import TagOperation from './tag-operation';
11
11
  import { isMobile } from '../../utils';
12
12
  import './style.css';
13
- import { useConfig } from '../../hooks';
14
13
  var DocOperations = function DocOperations(_ref) {
15
14
  var isShowChanges = _ref.isShowChanges,
15
+ _ref$isPublished = _ref.isPublished,
16
+ isPublished = _ref$isPublished === void 0 ? false : _ref$isPublished,
16
17
  changes = _ref.changes,
17
18
  handleViewChangesToggle = _ref.handleViewChangesToggle,
18
19
  handleRevisionMerged = _ref.handleRevisionMerged,
19
20
  handleRevisionPublished = _ref.handleRevisionPublished;
20
21
  var isSdocRevision = context.getSetting('isSdocRevision');
21
- var _useConfig = useConfig(),
22
- isPublished = _useConfig.isPublished;
23
22
  if (isMobile) {
24
23
  return /*#__PURE__*/React.createElement("div", {
25
24
  className: "doc-ops"
@@ -29,6 +28,7 @@ var DocOperations = function DocOperations(_ref) {
29
28
  className: "doc-ops"
30
29
  }, /*#__PURE__*/React.createElement(RevisionOperations, {
31
30
  isShowChanges: isShowChanges,
31
+ isPublished: isPublished,
32
32
  changes: changes,
33
33
  handleViewChangesToggle: handleViewChangesToggle,
34
34
  handleRevisionMerged: handleRevisionMerged,
@@ -3,8 +3,8 @@ import React, { useCallback, useEffect, useState } from 'react';
3
3
  import { EventBus } from '../../../basic-sdk';
4
4
  import { getRebase, hasConflict } from '../../../basic-sdk/utils/rebase';
5
5
  import context from '../../../context';
6
- import { EXTERNAL_EVENT, TIP_TYPE } from '../../../constants';
7
- import { useConfig, useDocument } from '../../../hooks';
6
+ import { EXTERNAL_EVENT, TIP_CONTENT, TIP_TYPE } from '../../../constants';
7
+ import { useDocument } from '../../../hooks';
8
8
  import toaster from '../../toast';
9
9
  import TipDialog from '../../tip-dialog';
10
10
  import { useTranslation } from 'react-i18next';
@@ -15,6 +15,8 @@ import Revisions from './revisions';
15
15
  import ChangesCount from './changes-count';
16
16
  var RevisionOperations = function RevisionOperations(_ref) {
17
17
  var isShowChanges = _ref.isShowChanges,
18
+ _ref$isPublished = _ref.isPublished,
19
+ isPublished = _ref$isPublished === void 0 ? false : _ref$isPublished,
18
20
  changes = _ref.changes,
19
21
  handleViewChangesToggle = _ref.handleViewChangesToggle,
20
22
  handleRevisionMerged = _ref.handleRevisionMerged,
@@ -36,8 +38,6 @@ var RevisionOperations = function RevisionOperations(_ref) {
36
38
  setMergeValue = _useState6[1];
37
39
  var _useDocument = useDocument(),
38
40
  loadDocument = _useDocument.loadDocument;
39
- var _useConfig = useConfig(),
40
- isPublished = _useConfig.isPublished;
41
41
  var onDocumentReplaced = useCallback(function () {
42
42
  if (isShowTip) return;
43
43
  setTipType(TIP_TYPE.HAS_BEEN_REPLACED);
@@ -45,7 +45,7 @@ var RevisionOperations = function RevisionOperations(_ref) {
45
45
  }, [isShowTip]);
46
46
  var hasPublishRevision = useCallback(function () {
47
47
  handleRevisionPublished();
48
- toaster.success(t('Revision published'));
48
+ toaster.success(t(TIP_CONTENT[TIP_TYPE.HAS_BEEN_PUBLISHED]));
49
49
  }, [handleRevisionPublished, t]);
50
50
  var onDocumentRemoved = useCallback(function () {
51
51
  if (isShowTip) return;
@@ -3,8 +3,7 @@ import React, { useCallback, useEffect, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
5
5
  import classnames from 'classnames';
6
- import { TIP_TYPE, TIP_TITLE } from '../../constants';
7
- import TipContent from './tip-content';
6
+ import { TIP_TYPE, TIP_TITLE, TIP_CONTENT } from '../../constants';
8
7
  import CommonLoading from '../common-loading';
9
8
  import './index.css';
10
9
  var NOT_CLOSE_DIALOG_TIP_TYPE = [TIP_TYPE.HAS_BEEN_REPLACED, TIP_TYPE.HAS_BEEN_PUBLISHED, TIP_TYPE.CHECKING, TIP_TYPE.PUBLISHING];
@@ -58,9 +57,7 @@ var TipDialog = function TipDialog(_ref) {
58
57
  toggle: NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) ? undefined : closeDialog
59
58
  }, t(TIP_TITLE[tipType])), /*#__PURE__*/React.createElement(ModalBody, {
60
59
  className: "sdoc-tip-body"
61
- }, children ? children : /*#__PURE__*/React.createElement(TipContent, {
62
- tipType: tipType
63
- })), !NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) && /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
60
+ }, children ? children : /*#__PURE__*/React.createElement(React.Fragment, null, t(TIP_CONTENT[tipType]))), !NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) && /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
64
61
  color: "secondary",
65
62
  className: "mr-2",
66
63
  onClick: closeDialog
@@ -1,3 +1,3 @@
1
- export { CollaboratorsProvider, useCollaborators } from './use-collaborators';
2
- export { useDocument } from './use-document';
3
- export { useConfig } from './use-config';
1
+ import { CollaboratorsProvider, useCollaborators } from './use-collaborators';
2
+ import { useDocument } from './use-document';
3
+ export { CollaboratorsProvider, useCollaborators, useDocument };
@@ -78,10 +78,12 @@ var PublishedRevisionViewer = function PublishedRevisionViewer() {
78
78
  }, t(errorMessage)));
79
79
  }
80
80
  return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
81
- isEditMode: false
81
+ isEditMode: false,
82
+ isPublished: true
82
83
  }), /*#__PURE__*/React.createElement(DocOperations, {
83
84
  isShowChanges: isShowChanges,
84
85
  changes: changes,
86
+ isPublished: true,
85
87
  handleViewChangesToggle: handleViewChangesToggle
86
88
  })), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(PublishedRevisionDiffViewer, {
87
89
  isShowChanges: isShowChanges,
@@ -9,7 +9,7 @@ import context from '../context';
9
9
  import ErrorBoundary from './error-boundary';
10
10
  import { SDocEditor } from '../basic-sdk';
11
11
  import { PublishedRevisionDiffViewer, RevisionDiffViewer } from '../basic-sdk/views';
12
- import { useDocument, useConfig } from '../hooks';
12
+ import { useDocument } from '../hooks';
13
13
  import { resetWebTitleAndURL } from '../utils';
14
14
  import '../assets/css/simple-editor.css';
15
15
  var SimpleEditor = function SimpleEditor(_ref) {
@@ -37,9 +37,11 @@ var SimpleEditor = function SimpleEditor(_ref) {
37
37
  _useState6 = _slicedToArray(_useState5, 2),
38
38
  changes = _useState6[0],
39
39
  setChanges = _useState6[1];
40
- var _useConfig = useConfig(),
41
- isPublished = _useConfig.isPublished,
42
- handelPublished = _useConfig.handelPublished;
40
+ var initIsPublished = context.getSetting('isPublished');
41
+ var _useState7 = useState(initIsPublished),
42
+ _useState8 = _slicedToArray(_useState7, 2),
43
+ isPublished = _useState8[0],
44
+ setPublished = _useState8[1];
43
45
 
44
46
  // useMount: reset title
45
47
  useEffect(function () {
@@ -77,8 +79,12 @@ var SimpleEditor = function SimpleEditor(_ref) {
77
79
  var revisionContentString = res.data.content;
78
80
  var document = JSON.parse(revisionContentString);
79
81
  setRevisionContent(document);
80
- handelPublished();
82
+ setPublished(true);
81
83
  context.settings['isPublished'] = true;
84
+ var oldAssetsUrl = context.getSetting('assetsUrl');
85
+ var docUuid = context.getSetting('docUuid');
86
+ var originDocUuid = context.getSetting('originDocUuid');
87
+ context.settings['assetsUrl'] = oldAssetsUrl.replace(docUuid, originDocUuid);
82
88
  }).catch(function (error) {
83
89
  // eslint-disable-next-line
84
90
  console.log(error);
@@ -91,9 +97,9 @@ var SimpleEditor = function SimpleEditor(_ref) {
91
97
  }
92
98
  }
93
99
  setErrorMessage(errorMessage);
94
- handelPublished();
100
+ setPublished(true);
95
101
  });
96
- }, [handelPublished, setErrorMessage]);
102
+ }, [setErrorMessage]);
97
103
  if (isFirstLoading) {
98
104
  return /*#__PURE__*/React.createElement(Loading, null);
99
105
  }
@@ -107,9 +113,11 @@ var SimpleEditor = function SimpleEditor(_ref) {
107
113
  return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
108
114
  isStarred: isStarred,
109
115
  isDraft: isDraft,
116
+ isPublished: isPublished,
110
117
  isEditMode: isPublished ? false : !isShowChanges
111
118
  }), /*#__PURE__*/React.createElement(DocOperations, {
112
119
  isShowChanges: isShowChanges,
120
+ isPublished: isPublished,
113
121
  changes: changes,
114
122
  handleViewChangesToggle: handleViewChangesToggle,
115
123
  handleRevisionMerged: handleRevisionMerged,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.2.24beta1",
3
+ "version": "0.2.24beta2",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -379,7 +379,7 @@
379
379
  "Tip": "Tip",
380
380
  "Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
381
381
  "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
382
- "Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
382
+ "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
384
384
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
385
385
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
@@ -406,5 +406,7 @@
406
406
  "Search_tags": "Search tags",
407
407
  "No_options_available": "Tag not found",
408
408
  "Add_option": "Vytvořit nový štítek",
409
- "Find_an_option": "Search tags"
409
+ "Find_an_option": "Search tags",
410
+ "Copy_link_of_section": "Copy link of section",
411
+ "revision": "revision"
410
412
  }
@@ -379,7 +379,7 @@
379
379
  "Tip": "Tip",
380
380
  "Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
381
381
  "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
382
- "Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
382
+ "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
384
384
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
385
385
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
@@ -379,7 +379,7 @@
379
379
  "Tip": "Tip",
380
380
  "Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
381
381
  "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
382
- "Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
382
+ "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
384
384
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
385
385
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
@@ -379,7 +379,7 @@
379
379
  "Tip": "Tip",
380
380
  "Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
381
381
  "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
382
- "Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
382
+ "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
384
384
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
385
385
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
@@ -379,7 +379,7 @@
379
379
  "Tip": "Tip",
380
380
  "Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
381
381
  "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
382
- "Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
382
+ "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
384
384
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
385
385
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
@@ -406,5 +406,7 @@
406
406
  "Search_tags": "Search tags",
407
407
  "No_options_available": "Tag not found",
408
408
  "Add_option": "Créer un nouveau Tag",
409
- "Find_an_option": "Search tags"
409
+ "Find_an_option": "Search tags",
410
+ "Copy_link_of_section": "Copy link of section",
411
+ "revision": "revision"
410
412
  }
@@ -379,7 +379,7 @@
379
379
  "Tip": "Tip",
380
380
  "Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
381
381
  "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
382
- "Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
382
+ "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
384
384
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
385
385
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
@@ -379,7 +379,7 @@
379
379
  "Tip": "Совет",
380
380
  "Rebase_delete_no_change_revision_tip": "Редакция не внесла никаких изменений по сравнению с исходным документом. Вы хотите удалить эту редакцию?",
381
381
  "Has_been_replaced_tip": "Содержимое документа было заменено. Обновите страницу.",
382
- "Has_been_published_tip": "Версия опубликована. Автоматический переход к исходному контенту через {{ time }} секунд.",
382
+ "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "В документе есть конфликты, разрешите их перед публикацией!",
384
384
  "Merge_tip": "В документах есть конфликты. Вы хотите объединить их?",
385
385
  "Has_conflict_before_view_changes_tip": "В документе есть конфликты. Разрешите конфликт перед просмотром изменений!",
@@ -379,7 +379,7 @@
379
379
  "Tip": "提示",
380
380
  "Rebase_delete_no_change_revision_tip": "修订改没有更改,是否删除修订稿?",
381
381
  "Has_been_replaced_tip": "文档内容已经被替换,请刷新页面。",
382
- "Has_been_published_tip": "修订稿已经发布了,{{ time }} 秒后自动跳转到源文件。",
382
+ "Has_been_published_tip": "修订稿已发布",
383
383
  "Has_conflict_before_publish_tip": "文档有冲突,请解决冲突后再发布!",
384
384
  "Merge_tip": "文档有冲突,是否合并?",
385
385
  "Has_conflict_before_view_changes_tip": "文档有冲突,请解决冲突后再查看更改!",
@@ -1,47 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import React, { useEffect, useState } from 'react';
3
- import PropTypes from 'prop-types';
4
- import { useTranslation } from 'react-i18next';
5
- import { TIP_TYPE, TIP_CONTENT } from '../../constants';
6
- import context from '../../context';
7
- var TipContent = function TipContent(_ref) {
8
- var tipType = _ref.tipType;
9
- var _useState = useState(3),
10
- _useState2 = _slicedToArray(_useState, 2),
11
- time = _useState2[0],
12
- setTime = _useState2[1];
13
- useEffect(function () {
14
- if (tipType === TIP_TYPE.HAS_BEEN_PUBLISHED) {
15
- var _time = 3;
16
- var timer = setInterval(function () {
17
- _time--;
18
- setTime(_time);
19
- if (_time === 0) {
20
- clearInterval(timer);
21
- timer = null;
22
- }
23
- }, 1000);
24
- return function () {
25
- timer && clearInterval(timer);
26
- };
27
- }
28
- }, [tipType]);
29
- useEffect(function () {
30
- if (time === 0) {
31
- var originFileURL = context.getSetting('originFileURL');
32
- window.location.href = originFileURL;
33
- }
34
- }, [time]);
35
- var _useTranslation = useTranslation(),
36
- t = _useTranslation.t;
37
- if (tipType === TIP_TYPE.HAS_BEEN_PUBLISHED) {
38
- return /*#__PURE__*/React.createElement(React.Fragment, null, t(TIP_CONTENT[tipType], {
39
- time: time
40
- }));
41
- }
42
- return /*#__PURE__*/React.createElement(React.Fragment, null, t(TIP_CONTENT[tipType]));
43
- };
44
- TipContent.propTypes = {
45
- tipType: PropTypes.string
46
- };
47
- export default TipContent;
@@ -1,18 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { useCallback, useState } from 'react';
3
- import context from '../context';
4
- export var useConfig = function useConfig() {
5
- var initIsPublished = context.getSetting('isPublished');
6
- var _useState = useState(initIsPublished),
7
- _useState2 = _slicedToArray(_useState, 2),
8
- isPublished = _useState2[0],
9
- setIsPublished = _useState2[1];
10
- var handelPublished = useCallback(function () {
11
- setIsPublished(true);
12
- context.settings['isPublished'] = true;
13
- }, []);
14
- return {
15
- isPublished: isPublished,
16
- handelPublished: handelPublished
17
- };
18
- };