@seafile/sdoc-editor 0.1.162 → 0.1.164

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.
@@ -2,7 +2,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
2
2
  var _excluded = ["text"];
3
3
  import React from 'react';
4
4
  import Caret from './caret';
5
- import { DEFAULT_FONT, TEXT_STYLE_MAP } from '../../constants';
5
+ import { TEXT_STYLE_MAP } from '../../constants';
6
6
  import { generatorFontFamily } from '../font/helpers';
7
7
  var renderText = function renderText(props, editor) {
8
8
  var attributes = props.attributes,
@@ -18,7 +18,7 @@ var SDocViewer = function SDocViewer(_ref) {
18
18
  var slateValue = (document || generateDefaultDocContent()).children;
19
19
  var decorate = usePipDecorate(validEditor);
20
20
  return /*#__PURE__*/React.createElement(EditorContainer, {
21
- editor: editor,
21
+ editor: validEditor,
22
22
  showToolbar: showToolbar,
23
23
  readonly: true
24
24
  }, /*#__PURE__*/React.createElement(EditorContent, {
@@ -4,6 +4,7 @@ import { withTranslation } from 'react-i18next';
4
4
  import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
5
5
  import context from '../../../../context';
6
6
  import toaster from '../../../toast';
7
+ import { REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../../../../constants';
7
8
  import './index.css';
8
9
  var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
9
10
  var t = _ref.t;
@@ -18,7 +19,7 @@ var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
18
19
  }, []);
19
20
  var startRevise = useCallback(function () {
20
21
  context.startRevise().then(function (res) {
21
- window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/");
22
+ window.location.href = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/?").concat(REVISION_FIRST_LOAD_KEY, "=").concat(REVISION_FIRST_LOAD_VALUE);
22
23
  }).catch(function (error) {
23
24
  toaster.danger(t('Error'));
24
25
  });
@@ -0,0 +1,4 @@
1
+ .sdoc-tip-dialog .highlight-bg-color {
2
+ background-color: #FF8000;
3
+ border-color: #FF8000;
4
+ }
@@ -1,10 +1,13 @@
1
- import React, { useCallback } from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useCallback, useState } from 'react';
2
3
  import { useTranslation } from 'react-i18next';
3
4
  import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
4
5
  import classnames from 'classnames';
5
6
  import { TIP_TYPE, TIP_TITLE } from '../../constants';
6
7
  import TipContent from './tip-content';
7
- var NOT_CLOSE_DIALOG_TIP_TYPE = [TIP_TYPE.HAS_BEEN_REPLACED, TIP_TYPE.HAS_BEEN_PUBLISHED];
8
+ import CommonLoading from '../common-loading';
9
+ import './index.css';
10
+ var NOT_CLOSE_DIALOG_TIP_TYPE = [TIP_TYPE.HAS_BEEN_REPLACED, TIP_TYPE.HAS_BEEN_PUBLISHED, TIP_TYPE.CHECKING, TIP_TYPE.PUBLISHING];
8
11
  var TipDialog = function TipDialog(_ref) {
9
12
  var className = _ref.className,
10
13
  tipType = _ref.tipType,
@@ -12,17 +15,24 @@ var TipDialog = function TipDialog(_ref) {
12
15
  submit = _ref.submit;
13
16
  var _useTranslation = useTranslation(),
14
17
  t = _useTranslation.t;
18
+ var _useState = useState(false),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ isSubmitting = _useState2[0],
21
+ setSubmitting = _useState2[1];
15
22
  var closeDialog = useCallback(function () {
16
23
  if (NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType)) return;
24
+ if (isSubmitting) return;
17
25
  toggle && toggle();
18
26
 
19
27
  // eslint-disable-next-line react-hooks/exhaustive-deps
20
- }, [tipType]);
28
+ }, [tipType, isSubmitting]);
21
29
  var confirmTip = useCallback(function () {
22
- submit && submit();
30
+ submit && submit(function (submitting) {
31
+ setSubmitting(submitting);
32
+ });
23
33
 
24
34
  // eslint-disable-next-line react-hooks/exhaustive-deps
25
- }, []);
35
+ }, [tipType]);
26
36
  return /*#__PURE__*/React.createElement(Modal, {
27
37
  isOpen: true,
28
38
  autoFocus: false,
@@ -43,8 +53,13 @@ var TipDialog = function TipDialog(_ref) {
43
53
  onClick: closeDialog
44
54
  }, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
45
55
  color: "primary",
46
- className: "highlight-bg-color",
47
- onClick: confirmTip
48
- }, t('Confirm'))));
56
+ className: classnames('highlight-bg-color', {
57
+ 'd-flex align-items-center': isSubmitting
58
+ }),
59
+ onClick: confirmTip,
60
+ disabled: isSubmitting
61
+ }, isSubmitting && /*#__PURE__*/React.createElement("span", {
62
+ className: "submit-loading-container mr-2"
63
+ }, /*#__PURE__*/React.createElement(CommonLoading, null)), t('Confirm'))));
49
64
  };
50
65
  export default TipDialog;
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  var _TIP_TITLE, _TIP_CONTENT;
3
+ export var REVISION_FIRST_LOAD_KEY = 'first-load';
4
+ export var REVISION_FIRST_LOAD_VALUE = '1';
3
5
  export var EXTERNAL_EVENT = {
4
6
  INTERNAL_LINK_CLICK: 'internal_link_click',
5
7
  TOGGLE_STAR: 'toggle_star',
@@ -24,7 +26,9 @@ export var TIP_TYPE = {
24
26
  HAS_BEEN_PUBLISHED: 'has_been_published',
25
27
  HAS_BEEN_REPLACED: 'has_been_merge',
26
28
  HAS_CONFLICT_BEFORE_VIEW_CHANGES: 'has_conflict_before_view_changes',
27
- HAS_BEEN_REMOVED: 'has_been_removed'
29
+ HAS_BEEN_REMOVED: 'has_been_removed',
30
+ CHECKING: 'checking',
31
+ PUBLISHING: 'publishing'
28
32
  };
29
- export var TIP_TITLE = (_TIP_TITLE = {}, _defineProperty(_TIP_TITLE, TIP_TYPE.DELETE_NO_CHANGES_REVISION, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.MERGE, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_CONFLICT_BEFORE_PUBLISH, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_BEEN_PUBLISHED, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_BEEN_REPLACED, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_CONFLICT_BEFORE_VIEW_CHANGES, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_BEEN_REMOVED, 'Tip'), _TIP_TITLE);
30
- export var TIP_CONTENT = (_TIP_CONTENT = {}, _defineProperty(_TIP_CONTENT, TIP_TYPE.DELETE_NO_CHANGES_REVISION, 'Rebase_delete_no_change_revision_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.MERGE, 'Merge_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_CONFLICT_BEFORE_PUBLISH, 'Has_conflict_before_publish_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_BEEN_PUBLISHED, 'Has_been_published_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_BEEN_REPLACED, 'Has_been_replaced_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_CONFLICT_BEFORE_VIEW_CHANGES, 'Has_conflict_before_view_changes_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_BEEN_REMOVED, 'Has_been_removed_tip'), _TIP_CONTENT);
33
+ export var TIP_TITLE = (_TIP_TITLE = {}, _defineProperty(_TIP_TITLE, TIP_TYPE.DELETE_NO_CHANGES_REVISION, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.MERGE, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_CONFLICT_BEFORE_PUBLISH, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_BEEN_PUBLISHED, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_BEEN_REPLACED, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_CONFLICT_BEFORE_VIEW_CHANGES, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.HAS_BEEN_REMOVED, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.CHECKING, 'Tip'), _defineProperty(_TIP_TITLE, TIP_TYPE.PUBLISHING, 'Tip'), _TIP_TITLE);
34
+ export var TIP_CONTENT = (_TIP_CONTENT = {}, _defineProperty(_TIP_CONTENT, TIP_TYPE.DELETE_NO_CHANGES_REVISION, 'Rebase_delete_no_change_revision_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.MERGE, 'Merge_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_CONFLICT_BEFORE_PUBLISH, 'Has_conflict_before_publish_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_BEEN_PUBLISHED, 'Has_been_published_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_BEEN_REPLACED, 'Has_been_replaced_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_CONFLICT_BEFORE_VIEW_CHANGES, 'Has_conflict_before_view_changes_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.HAS_BEEN_REMOVED, 'Has_been_removed_tip'), _defineProperty(_TIP_CONTENT, TIP_TYPE.CHECKING, 'Checking'), _defineProperty(_TIP_CONTENT, TIP_TYPE.PUBLISHING, 'Publishing'), _TIP_CONTENT);
@@ -11,7 +11,7 @@ import { generateDefaultDocContent } from '../utils';
11
11
  import context from '../context';
12
12
  import ErrorBoundary from './error-boundary';
13
13
  import TipDialog from '../components/tip-dialog';
14
- import { EXTERNAL_EVENT, MODE, TIP_TYPE } from '../constants';
14
+ import { EXTERNAL_EVENT, MODE, TIP_TYPE, REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../constants';
15
15
  import { getRebase, hasConflict } from '../basic-sdk/utils/rebase';
16
16
  import toaster from '../components/toast';
17
17
  import { EventBus, SDocEditor } from '../basic-sdk';
@@ -79,6 +79,18 @@ var SimpleEditor = function SimpleEditor(_ref) {
79
79
  var originFilename = context.getSetting('originFilename');
80
80
  if (isSdocRevision) {
81
81
  window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
82
+
83
+ // show revision created success info
84
+ var url = new URL(window.location.href);
85
+ var searchParams = new URLSearchParams(url.search);
86
+ if (!searchParams.has(REVISION_FIRST_LOAD_KEY)) return;
87
+ var firstLoadValue = searchParams.get(REVISION_FIRST_LOAD_KEY);
88
+ if (firstLoadValue === REVISION_FIRST_LOAD_VALUE) {
89
+ var revisionId = context.getSetting('revisionId');
90
+ toaster.success(t('Revision_created', {
91
+ id: revisionId
92
+ }));
93
+ }
82
94
  }
83
95
 
84
96
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -195,6 +207,8 @@ var SimpleEditor = function SimpleEditor(_ref) {
195
207
  return _regeneratorRuntime().wrap(function _callee$(_context) {
196
208
  while (1) switch (_context.prev = _context.next) {
197
209
  case 0:
210
+ setTipType(TIP_TYPE.CHECKING);
211
+ setShowTip(true);
198
212
  loadDocument(function (document) {
199
213
  var revisionContent = document;
200
214
  if (hasConflict(revisionContent.children)) {
@@ -216,6 +230,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
216
230
  isNeedReplaceMaster = _getRebase.isNeedReplaceMaster,
217
231
  value = _getRebase.value;
218
232
  if (canMerge && isNeedReplaceMaster) {
233
+ setTipType(TIP_TYPE.PUBLISHING);
219
234
  context.publishRevision().then(function (res) {
220
235
  setTipType(TIP_TYPE.HAS_BEEN_PUBLISHED);
221
236
  setShowTip(true);
@@ -240,7 +255,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
240
255
  });
241
256
 
242
257
  // eslint-disable-next-line react-hooks/exhaustive-deps
243
- case 1:
258
+ case 3:
244
259
  case "end":
245
260
  return _context.stop();
246
261
  }
@@ -259,18 +274,22 @@ var SimpleEditor = function SimpleEditor(_ref) {
259
274
 
260
275
  // eslint-disable-next-line react-hooks/exhaustive-deps
261
276
  }, [tipType]);
262
- var tipSubmit = useCallback(function () {
277
+ var tipSubmit = useCallback(function (callback) {
263
278
  if (tipType === TIP_TYPE.DELETE_NO_CHANGES_REVISION) {
279
+ callback && callback(true);
264
280
  context.deleteSdocRevision().then(function (res) {
281
+ callback && callback(false);
265
282
  setShowTip(false);
266
283
  var originFileURL = context.getSetting('originFileURL');
267
284
  jumpToURL(originFileURL);
268
285
  }).catch(function (error) {
286
+ callback && callback(false);
269
287
  toaster.danger(t('Error'));
270
288
  });
271
289
  return;
272
290
  }
273
291
  if (tipType === TIP_TYPE.MERGE) {
292
+ callback && callback(true);
274
293
  var _context$getUserInfo = context.getUserInfo(),
275
294
  username = _context$getUserInfo.username;
276
295
  var doc = {
@@ -281,6 +300,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
281
300
  last_modify_user: username
282
301
  };
283
302
  context.updateSdocRevision(doc).then(function (res) {
303
+ callback && callback(false);
284
304
  var origin_file_version = res.data.origin_file_version;
285
305
  context.updateSettings({
286
306
  'originFileVersion': origin_file_version
@@ -293,6 +313,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
293
313
  editorRef.current.setLoading(false);
294
314
  setShowTip(false);
295
315
  }).catch(function (error) {
316
+ callback && callback(false);
296
317
  toaster.danger(t('Error'));
297
318
  });
298
319
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.162",
3
+ "version": "0.1.164",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -375,5 +375,8 @@
375
375
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
376
376
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
377
377
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
378
- "Has_been_removed_tip": "Document has been removed, please view other documents."
378
+ "Has_been_removed_tip": "Document has been removed, please view other documents.",
379
+ "Revision_created": "Revision {{id}} created",
380
+ "Checking": "Checking...",
381
+ "Publishing": "Publishing..."
379
382
  }
@@ -375,5 +375,8 @@
375
375
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
376
376
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
377
377
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
378
- "Has_been_removed_tip": "Document has been removed, please view other documents."
378
+ "Has_been_removed_tip": "Document has been removed, please view other documents.",
379
+ "Revision_created": "Revision {{id}} created",
380
+ "Checking": "Checking...",
381
+ "Publishing": "Publishing..."
379
382
  }
@@ -375,5 +375,8 @@
375
375
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
376
376
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
377
377
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
378
- "Has_been_removed_tip": "Document has been removed, please view other documents."
378
+ "Has_been_removed_tip": "Document has been removed, please view other documents.",
379
+ "Revision_created": "Revision {{id}} created",
380
+ "Checking": "Checking...",
381
+ "Publishing": "Publishing..."
379
382
  }
@@ -375,5 +375,8 @@
375
375
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
376
376
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
377
377
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
378
- "Has_been_removed_tip": "Document has been removed, please view other documents."
378
+ "Has_been_removed_tip": "Document has been removed, please view other documents.",
379
+ "Revision_created": "Revision {{id}} created",
380
+ "Checking": "Checking...",
381
+ "Publishing": "Publishing..."
379
382
  }
@@ -375,5 +375,8 @@
375
375
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
376
376
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
377
377
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
378
- "Has_been_removed_tip": "Document has been removed, please view other documents."
378
+ "Has_been_removed_tip": "Document has been removed, please view other documents.",
379
+ "Revision_created": "Revision {{id}} created",
380
+ "Checking": "Checking...",
381
+ "Publishing": "Publishing..."
379
382
  }
@@ -375,5 +375,8 @@
375
375
  "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
376
376
  "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
377
377
  "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
378
- "Has_been_removed_tip": "Document has been removed, please view other documents."
378
+ "Has_been_removed_tip": "Document has been removed, please view other documents.",
379
+ "Revision_created": "Revision {{id}} created",
380
+ "Checking": "Checking...",
381
+ "Publishing": "Publishing..."
379
382
  }
@@ -365,15 +365,18 @@
365
365
  "Subtitle": "Подзаголовок",
366
366
  "Link_sdoc": "Ссылка на sdoc",
367
367
  "Link_file": "Ссылка на файл",
368
- "Keep_my_modification": "Keep my modification",
369
- "Keep_other_modification": "Keep other's modification",
370
- "Keep_both_modification": "Keep my modification",
371
- "Tip": "Tip",
372
- "Rebase_delete_no_change_revision_tip": "Revision has not made any change compared to original document. Do you want to delete this revision?",
373
- "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
374
- "Has_been_published_tip": "Revision has been published, Automatically jump to source content after {{ time }} seconds.",
375
- "Has_conflict_before_publish_tip": "There are conflicts in the document, please resolve it before publishing!",
376
- "Merge_tip": "There are conflicts in the documents. Do you want to merge them?",
377
- "Has_conflict_before_view_changes_tip": "There are conflicts in the document. Please resolve the conflict before viewing the changes!",
378
- "Has_been_removed_tip": "Document has been removed, please view other documents."
368
+ "Keep_my_modification": "Сохранить мою модификацию",
369
+ "Keep_other_modification": "Сохранить чужую модификацию",
370
+ "Keep_both_modification": "Сохранить мою модификацию",
371
+ "Tip": "Совет",
372
+ "Rebase_delete_no_change_revision_tip": "Редакция не внесла никаких изменений по сравнению с исходным документом. Вы хотите удалить эту редакцию?",
373
+ "Has_been_replaced_tip": "Содержимое документа было заменено. Обновите страницу.",
374
+ "Has_been_published_tip": "Версия опубликована. Автоматический переход к исходному контенту через {{ time }} секунд.",
375
+ "Has_conflict_before_publish_tip": "В документе есть конфликты, разрешите их перед публикацией!",
376
+ "Merge_tip": "В документах есть конфликты. Вы хотите объединить их?",
377
+ "Has_conflict_before_view_changes_tip": "В документе есть конфликты. Разрешите конфликт перед просмотром изменений!",
378
+ "Has_been_removed_tip": "Документ удален, посмотрите другие документы.",
379
+ "Revision_created": "Revision {{id}} created",
380
+ "Checking": "Checking...",
381
+ "Publishing": "Publishing..."
379
382
  }
@@ -375,5 +375,8 @@
375
375
  "Has_conflict_before_publish_tip": "文档有冲突,请解决冲突后再发布!",
376
376
  "Merge_tip": "文档有冲突,是否合并?",
377
377
  "Has_conflict_before_view_changes_tip": "文档有冲突,请解决冲突后再查看更改!",
378
- "Has_been_removed_tip": "文档已经被删除,请查看其他文档"
378
+ "Has_been_removed_tip": "文档已经被删除,请查看其他文档",
379
+ "Revision_created": "已创建修订稿 {{id}}",
380
+ "Checking": "检查中...",
381
+ "Publishing": "发布中..."
379
382
  }