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

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,14 +8,15 @@ 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';
11
12
  import './index.css';
12
13
  var DocInfo = function DocInfo(_ref) {
13
14
  var t = _ref.t,
14
15
  isStarred = _ref.isStarred,
15
16
  isDraft = _ref.isDraft,
16
- isEditMode = _ref.isEditMode,
17
- _ref$isPublished = _ref.isPublished,
18
- isPublished = _ref$isPublished === void 0 ? false : _ref$isPublished;
17
+ isEditMode = _ref.isEditMode;
18
+ var _useConfig = useConfig(),
19
+ isPublished = _useConfig.isPublished;
19
20
  var onInternalLinkClick = useCallback(function () {
20
21
  var eventBus = EventBus.getInstance();
21
22
  eventBus.dispatch(EXTERNAL_EVENT.INTERNAL_LINK_CLICK);
@@ -10,15 +10,16 @@ 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';
13
14
  var DocOperations = function DocOperations(_ref) {
14
15
  var isShowChanges = _ref.isShowChanges,
15
- _ref$isPublished = _ref.isPublished,
16
- isPublished = _ref$isPublished === void 0 ? false : _ref$isPublished,
17
16
  changes = _ref.changes,
18
17
  handleViewChangesToggle = _ref.handleViewChangesToggle,
19
18
  handleRevisionMerged = _ref.handleRevisionMerged,
20
19
  handleRevisionPublished = _ref.handleRevisionPublished;
21
20
  var isSdocRevision = context.getSetting('isSdocRevision');
21
+ var _useConfig = useConfig(),
22
+ isPublished = _useConfig.isPublished;
22
23
  if (isMobile) {
23
24
  return /*#__PURE__*/React.createElement("div", {
24
25
  className: "doc-ops"
@@ -28,7 +29,6 @@ var DocOperations = function DocOperations(_ref) {
28
29
  className: "doc-ops"
29
30
  }, /*#__PURE__*/React.createElement(RevisionOperations, {
30
31
  isShowChanges: isShowChanges,
31
- isPublished: isPublished,
32
32
  changes: changes,
33
33
  handleViewChangesToggle: handleViewChangesToggle,
34
34
  handleRevisionMerged: handleRevisionMerged,
@@ -4,7 +4,7 @@ import { EventBus } from '../../../basic-sdk';
4
4
  import { getRebase, hasConflict } from '../../../basic-sdk/utils/rebase';
5
5
  import context from '../../../context';
6
6
  import { EXTERNAL_EVENT, TIP_TYPE } from '../../../constants';
7
- import { useDocument } from '../../../hooks';
7
+ import { useConfig, useDocument } from '../../../hooks';
8
8
  import toaster from '../../toast';
9
9
  import TipDialog from '../../tip-dialog';
10
10
  import { useTranslation } from 'react-i18next';
@@ -15,8 +15,6 @@ 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,
20
18
  changes = _ref.changes,
21
19
  handleViewChangesToggle = _ref.handleViewChangesToggle,
22
20
  handleRevisionMerged = _ref.handleRevisionMerged,
@@ -38,6 +36,8 @@ var RevisionOperations = function RevisionOperations(_ref) {
38
36
  setMergeValue = _useState6[1];
39
37
  var _useDocument = useDocument(),
40
38
  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);
@@ -1,3 +1,3 @@
1
- import { CollaboratorsProvider, useCollaborators } from './use-collaborators';
2
- import { useDocument } from './use-document';
3
- export { CollaboratorsProvider, useCollaborators, useDocument };
1
+ export { CollaboratorsProvider, useCollaborators } from './use-collaborators';
2
+ export { useDocument } from './use-document';
3
+ export { useConfig } from './use-config';
@@ -0,0 +1,18 @@
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
+ };
@@ -78,12 +78,10 @@ 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,
82
- isPublished: true
81
+ isEditMode: false
83
82
  }), /*#__PURE__*/React.createElement(DocOperations, {
84
83
  isShowChanges: isShowChanges,
85
84
  changes: changes,
86
- isPublished: true,
87
85
  handleViewChangesToggle: handleViewChangesToggle
88
86
  })), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(PublishedRevisionDiffViewer, {
89
87
  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 } from '../hooks';
12
+ import { useDocument, useConfig } from '../hooks';
13
13
  import { resetWebTitleAndURL } from '../utils';
14
14
  import '../assets/css/simple-editor.css';
15
15
  var SimpleEditor = function SimpleEditor(_ref) {
@@ -37,11 +37,9 @@ var SimpleEditor = function SimpleEditor(_ref) {
37
37
  _useState6 = _slicedToArray(_useState5, 2),
38
38
  changes = _useState6[0],
39
39
  setChanges = _useState6[1];
40
- var initIsPublished = context.getSetting('isPublished');
41
- var _useState7 = useState(initIsPublished),
42
- _useState8 = _slicedToArray(_useState7, 2),
43
- isPublished = _useState8[0],
44
- setPublished = _useState8[1];
40
+ var _useConfig = useConfig(),
41
+ isPublished = _useConfig.isPublished,
42
+ handelPublished = _useConfig.handelPublished;
45
43
 
46
44
  // useMount: reset title
47
45
  useEffect(function () {
@@ -79,7 +77,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
79
77
  var revisionContentString = res.data.content;
80
78
  var document = JSON.parse(revisionContentString);
81
79
  setRevisionContent(document);
82
- setPublished(true);
80
+ handelPublished();
83
81
  context.settings['isPublished'] = true;
84
82
  }).catch(function (error) {
85
83
  // eslint-disable-next-line
@@ -93,9 +91,9 @@ var SimpleEditor = function SimpleEditor(_ref) {
93
91
  }
94
92
  }
95
93
  setErrorMessage(errorMessage);
96
- setPublished(true);
94
+ handelPublished();
97
95
  });
98
- }, [setErrorMessage]);
96
+ }, [handelPublished, setErrorMessage]);
99
97
  if (isFirstLoading) {
100
98
  return /*#__PURE__*/React.createElement(Loading, null);
101
99
  }
@@ -109,11 +107,9 @@ var SimpleEditor = function SimpleEditor(_ref) {
109
107
  return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement(Header, null, /*#__PURE__*/React.createElement(DocInfo, {
110
108
  isStarred: isStarred,
111
109
  isDraft: isDraft,
112
- isPublished: isPublished,
113
110
  isEditMode: isPublished ? false : !isShowChanges
114
111
  }), /*#__PURE__*/React.createElement(DocOperations, {
115
112
  isShowChanges: isShowChanges,
116
- isPublished: isPublished,
117
113
  changes: changes,
118
114
  handleViewChangesToggle: handleViewChangesToggle,
119
115
  handleRevisionMerged: handleRevisionMerged,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.2.24beta",
3
+ "version": "0.2.24beta1",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",