@seafile/sdoc-editor 0.2.26 → 0.2.28

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 (33) hide show
  1. package/dist/assets/images/content-replaced.png +0 -0
  2. package/dist/basic-sdk/extension/constants/element-type.js +3 -1
  3. package/dist/basic-sdk/extension/constants/index.js +2 -2
  4. package/dist/basic-sdk/extension/plugins/html/helper.js +18 -16
  5. package/dist/basic-sdk/extension/plugins/html/rules/blockquote.js +0 -1
  6. package/dist/basic-sdk/extension/plugins/html/rules/check-list.js +0 -2
  7. package/dist/basic-sdk/extension/plugins/html/rules/code-block.js +0 -10
  8. package/dist/basic-sdk/extension/plugins/html/rules/header.js +0 -1
  9. package/dist/basic-sdk/extension/plugins/html/rules/image.js +0 -1
  10. package/dist/basic-sdk/extension/plugins/html/rules/link.js +0 -2
  11. package/dist/basic-sdk/extension/plugins/html/rules/list.js +0 -6
  12. package/dist/basic-sdk/extension/plugins/html/rules/paragraph.js +0 -1
  13. package/dist/basic-sdk/extension/plugins/html/rules/table.js +0 -3
  14. package/dist/basic-sdk/extension/plugins/html/rules/text.js +0 -7
  15. package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +2 -2
  16. package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +1 -2
  17. package/dist/components/doc-operations/tag-operation/tag-popover/index.css +4 -2
  18. package/dist/components/doc-operations/tag-operation/tag-popover/index.js +1 -1
  19. package/dist/components/tip-dialog/index.css +27 -0
  20. package/dist/components/tip-dialog/index.js +44 -18
  21. package/dist/constants/index.js +0 -2
  22. package/dist/pages/published-revision-viewer.js +2 -2
  23. package/dist/pages/simple-editor.js +3 -3
  24. package/dist/utils/index.js +1 -32
  25. package/package.json +1 -1
  26. package/public/locales/cs/sdoc-editor.json +1 -1
  27. package/public/locales/de/sdoc-editor.json +1 -1
  28. package/public/locales/en/sdoc-editor.json +1 -2
  29. package/public/locales/es/sdoc-editor.json +1 -1
  30. package/public/locales/fr/sdoc-editor.json +1 -1
  31. package/public/locales/it/sdoc-editor.json +1 -1
  32. package/public/locales/ru/sdoc-editor.json +1 -1
  33. package/public/locales/zh_CN/sdoc-editor.json +1 -1
@@ -27,4 +27,6 @@ export var IMAGE = 'image';
27
27
  // font
28
28
  export var FONT_SIZE = 'font-size';
29
29
  export var FONT_SIZE_INCREASE = 'font-size-increase';
30
- export var FONT_SIZE_REDUCE = 'font-size-reduce';
30
+ export var FONT_SIZE_REDUCE = 'font-size-reduce';
31
+ export var TOP_LEVEL_TYPES = [BLOCKQUOTE, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, PARAGRAPH, CODE_BLOCK, TABLE];
32
+ export var INLINE_LEVEL_TYPES = [IMAGE, LINK];
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  var _HEADER_TITLE_MAP, _FILE_TYPE;
3
3
  // extension plugin
4
4
  import * as ELEMENT_TYPE from './element-type';
5
- import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE } from './element-type';
5
+ import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES } from './element-type';
6
6
  export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from './color';
7
7
  export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
8
8
  export { DIFF_TYPE, ADDED_STYLE, DELETED_STYLE } from './diff-view';
@@ -25,4 +25,4 @@ export var LIST_ITEM_CORRELATION_TYPE = [UNORDERED_LIST, ORDERED_LIST, LIST_ITEM
25
25
  export var LIST_ITEM_SUPPORTED_TRANSFORMATION = [UNORDERED_LIST, ORDERED_LIST, 'left', 'center', 'right', BLOCKQUOTE];
26
26
  export var ADD_POSITION_OFFSET_TYPE = [PARAGRAPH, SUBTITLE, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, CHECK_LIST_ITEM];
27
27
  export var FILE_TYPE = (_FILE_TYPE = {}, _defineProperty(_FILE_TYPE, FILE_LINK, 'file'), _defineProperty(_FILE_TYPE, SDOC_LINK, 'sdoc'), _FILE_TYPE);
28
- export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE };
28
+ export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES };
@@ -1,6 +1,6 @@
1
1
  import slugid from 'slugid';
2
2
  import typeOf from 'type-of';
3
- import { LIST_ITEM, PARAGRAPH, UNORDERED_LIST } from '../../constants';
3
+ import { INLINE_LEVEL_TYPES, LIST_ITEM, PARAGRAPH, TOP_LEVEL_TYPES, UNORDERED_LIST } from '../../constants';
4
4
  import rules from './rules';
5
5
  var cruftNewline = function cruftNewline(element) {
6
6
  return !(element.nodeName === '#text' && element.nodeValue === '\n');
@@ -74,29 +74,32 @@ var deserializeElements = function deserializeElements() {
74
74
  var formatElementNodes = function formatElementNodes(nodes) {
75
75
  if (nodes.length === 0) return nodes;
76
76
  nodes = nodes.reduce(function (memo, node) {
77
- if (node.level === 'level1') {
77
+ if (TOP_LEVEL_TYPES.includes(node.type)) {
78
78
  memo.push(node);
79
79
  }
80
- if (node.level === 'level2') {
81
- if (node.type === LIST_ITEM) {
82
- var newNode = {
83
- level: 'level1',
84
- id: slugid.nice(),
85
- type: UNORDERED_LIST,
86
- children: [node]
87
- };
88
- memo.push(newNode);
89
- return memo;
90
- }
80
+ if (node.type === LIST_ITEM) {
81
+ var newNode = {
82
+ id: slugid.nice(),
83
+ type: UNORDERED_LIST,
84
+ children: [node]
85
+ };
86
+ memo.push(newNode);
87
+ return memo;
91
88
  }
92
- if (node.level === 'level3') {
89
+
90
+ // The following types will not appear individually during the pasting process
91
+ // code_line
92
+ // list_lic
93
+ // table_row | table_cell
94
+
95
+ // text | image | link
96
+ if (!node.type || INLINE_LEVEL_TYPES.includes(node.type)) {
93
97
  var prevNode = memo[memo.length - 1];
94
98
  if (prevNode && prevNode.type === PARAGRAPH) {
95
99
  prevNode.children.push(node);
96
100
  return memo;
97
101
  }
98
102
  var _newNode = {
99
- level: 'level1',
100
103
  id: slugid.nice(),
101
104
  type: PARAGRAPH,
102
105
  children: [node]
@@ -121,7 +124,6 @@ export var deserializeHtml = function deserializeHtml(html) {
121
124
  nodes = formatElementNodes(nodes);
122
125
  if (nodes.length === 0) {
123
126
  nodes = [{
124
- level: 'level1',
125
127
  id: slugid.nice(),
126
128
  type: PARAGRAPH,
127
129
  children: [{
@@ -5,7 +5,6 @@ var blockquoteRule = function blockquoteRule(element, parseChild) {
5
5
  childNodes = element.childNodes;
6
6
  if (nodeName === 'BLOCKQUOTE') {
7
7
  return {
8
- level: 'level1',
9
8
  id: slugid.nice(),
10
9
  type: BLOCKQUOTE,
11
10
  children: parseChild(childNodes)
@@ -4,12 +4,10 @@ var checkListRule = function checkListRule(element, parseChild) {
4
4
  var nodeName = element.nodeName;
5
5
  if (nodeName === 'INPUT' && element.getAttribute('type') === 'checkbox') {
6
6
  return {
7
- level: 'level1',
8
7
  id: slugid.nice(),
9
8
  type: CHECK_LIST_ITEM,
10
9
  checked: element.getAttribute('checked') !== null,
11
10
  children: [{
12
- level: 'level3',
13
11
  id: slugid.nice(),
14
12
  text: ''
15
13
  }]
@@ -15,7 +15,6 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
15
15
  return item.value === lang;
16
16
  }) || 'plaintext';
17
17
  return {
18
- level: 'level1',
19
18
  id: slugid.nice(),
20
19
  language: lang,
21
20
  type: CODE_BLOCK,
@@ -26,18 +25,15 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
26
25
  var content = childNodes[0].textContent;
27
26
  var _children = content.split('\n').map(function (text) {
28
27
  return {
29
- level: 'level2',
30
28
  id: slugid.nice(),
31
29
  type: CODE_LINE,
32
30
  children: [{
33
- level: 'level3',
34
31
  id: slugid.nice(),
35
32
  text: text
36
33
  }]
37
34
  };
38
35
  });
39
36
  return {
40
- level: 'level1',
41
37
  id: slugid.nice(),
42
38
  language: _lang,
43
39
  type: CODE_BLOCK,
@@ -52,11 +48,9 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
52
48
  if (childIsP) {
53
49
  return Array.from(childNodes).map(function (n) {
54
50
  return {
55
- level: 'level2',
56
51
  id: slugid.nice(),
57
52
  type: CODE_LINE,
58
53
  children: [{
59
- level: 'level3',
60
54
  id: slugid.nice(),
61
55
  text: n.textContent
62
56
  }]
@@ -67,11 +61,9 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
67
61
  var hasNewLine = _content.indexOf('\n') > -1;
68
62
  if (!hasNewLine) {
69
63
  return {
70
- level: 'level2',
71
64
  id: slugid.nice(),
72
65
  type: CODE_LINE,
73
66
  children: [{
74
- level: 'level3',
75
67
  id: slugid.nice(),
76
68
  text: element.textContent
77
69
  }]
@@ -80,11 +72,9 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
80
72
  var codes = _content.split('\n');
81
73
  return codes.map(function (item) {
82
74
  return {
83
- level: 'level2',
84
75
  id: slugid.nice(),
85
76
  type: CODE_LINE,
86
77
  children: [{
87
- level: 'level3',
88
78
  id: slugid.nice(),
89
79
  text: item
90
80
  }]
@@ -13,7 +13,6 @@ var headerRule = function headerRule(element, parseChild) {
13
13
  childNodes = element.childNodes;
14
14
  if (nodeName && HEADER_LIST.includes(nodeName)) {
15
15
  return {
16
- level: 'level1',
17
16
  id: slugid.nice(),
18
17
  type: HEADER_TYPE_MAP[nodeName],
19
18
  children: parseChild(childNodes)
@@ -4,7 +4,6 @@ var imageRule = function imageRule(element, parseChild) {
4
4
  var nodeName = element.nodeName;
5
5
  if (nodeName === 'IMG') {
6
6
  return {
7
- level: 'level3',
8
7
  id: slugid.nice(),
9
8
  type: IMAGE,
10
9
  data: {
@@ -5,13 +5,11 @@ var linkRule = function linkRule(element, parseChild) {
5
5
  var content = element.textContent || element.getAttribute('title') || element.getAttribute('href');
6
6
  if (nodeName === 'A') {
7
7
  return {
8
- level: 'level3',
9
8
  id: slugid.nice(),
10
9
  type: LINK,
11
10
  href: element.getAttribute('href'),
12
11
  title: element.getAttribute('title'),
13
12
  children: [{
14
- level: 'level3',
15
13
  id: slugid.nice(),
16
14
  text: content
17
15
  }]
@@ -6,7 +6,6 @@ var listRule = function listRule(element, parseChild) {
6
6
  childNodes = element.childNodes;
7
7
  if (nodeName === 'UL') {
8
8
  return {
9
- level: 'level1',
10
9
  id: slugid.nice(),
11
10
  type: UNORDERED_LIST,
12
11
  children: parseChild(childNodes)
@@ -14,7 +13,6 @@ var listRule = function listRule(element, parseChild) {
14
13
  }
15
14
  if (nodeName === 'OL') {
16
15
  return {
17
- level: 'level1',
18
16
  id: slugid.nice(),
19
17
  type: ORDERED_LIST,
20
18
  children: parseChild(childNodes)
@@ -22,7 +20,6 @@ var listRule = function listRule(element, parseChild) {
22
20
  }
23
21
  if (nodeName === 'LI' && PARAGRAPH_TAGS.includes(element.firstChild.nodeName)) {
24
22
  return {
25
- level: 'level2',
26
23
  id: slugid.nice(),
27
24
  type: LIST_ITEM,
28
25
  children: parseChild(childNodes)
@@ -30,12 +27,10 @@ var listRule = function listRule(element, parseChild) {
30
27
  }
31
28
  if (nodeName === 'LI' && !PARAGRAPH_TAGS.includes(element.firstChild.nodeName)) {
32
29
  return {
33
- level: 'level2',
34
30
  id: slugid.nice(),
35
31
  type: LIST_ITEM,
36
32
  children: [{
37
33
  id: slugid.nice(),
38
- level: 'level3',
39
34
  type: LIST_LIC,
40
35
  children: parseChild(childNodes)
41
36
  }]
@@ -43,7 +38,6 @@ var listRule = function listRule(element, parseChild) {
43
38
  }
44
39
  if (PARAGRAPH_TAGS.includes(nodeName) && element.parentElement.nodeName === 'LI') {
45
40
  return {
46
- level: 'level3',
47
41
  id: slugid.nice(),
48
42
  type: LIST_LIC,
49
43
  children: parseChild(childNodes)
@@ -5,7 +5,6 @@ var paragraphRule = function paragraphRule(element, parseChild) {
5
5
  childNodes = element.childNodes;
6
6
  if (nodeName === 'P' && element.parentElement.nodeName !== 'LI') {
7
7
  return {
8
- level: 'level1',
9
8
  id: slugid.nice(),
10
9
  type: PARAGRAPH,
11
10
  children: parseChild(childNodes)
@@ -5,7 +5,6 @@ var tableRule = function tableRule(element, parseChild) {
5
5
  childNodes = element.childNodes;
6
6
  if (nodeName === 'TABLE') {
7
7
  return {
8
- level: 'level1',
9
8
  id: slugid.nice(),
10
9
  type: TABLE,
11
10
  children: parseChild(childNodes)
@@ -16,7 +15,6 @@ var tableRule = function tableRule(element, parseChild) {
16
15
  }
17
16
  if (nodeName === 'TR') {
18
17
  return {
19
- level: 'level2',
20
18
  id: slugid.nice(),
21
19
  type: TABLE_ROW,
22
20
  children: parseChild(childNodes)
@@ -24,7 +22,6 @@ var tableRule = function tableRule(element, parseChild) {
24
22
  }
25
23
  if (nodeName === 'TH' || nodeName === 'TD') {
26
24
  return {
27
- level: 'level3',
28
25
  id: slugid.nice(),
29
26
  type: TABLE_CELL,
30
27
  children: parseChild(childNodes)
@@ -4,14 +4,12 @@ var textRule = function textRule(element, parseChild) {
4
4
  nodeType = element.nodeType;
5
5
  if (nodeName === 'SPAN') {
6
6
  return {
7
- level: 'level3',
8
7
  id: slugid.nice(),
9
8
  text: element.textContent
10
9
  };
11
10
  }
12
11
  if (nodeName === 'STRONG' || nodeName === 'B') {
13
12
  return {
14
- level: 'level3',
15
13
  id: slugid.nice(),
16
14
  bold: true,
17
15
  text: element.textContent
@@ -19,7 +17,6 @@ var textRule = function textRule(element, parseChild) {
19
17
  }
20
18
  if (nodeName === 'CODE' && element.parentElement.nodeName !== 'PRE') {
21
19
  return {
22
- level: 'level3',
23
20
  id: slugid.nice(),
24
21
  code: true,
25
22
  text: element.textContent
@@ -27,7 +24,6 @@ var textRule = function textRule(element, parseChild) {
27
24
  }
28
25
  if (nodeName === 'DEL') {
29
26
  return {
30
- level: 'level3',
31
27
  id: slugid.nice(),
32
28
  delete: true,
33
29
  text: element.textContent
@@ -35,7 +31,6 @@ var textRule = function textRule(element, parseChild) {
35
31
  }
36
32
  if (nodeName === 'I') {
37
33
  return {
38
- level: 'level3',
39
34
  id: slugid.nice(),
40
35
  italic: true,
41
36
  text: element.textContent
@@ -43,7 +38,6 @@ var textRule = function textRule(element, parseChild) {
43
38
  }
44
39
  if (nodeName === 'INS') {
45
40
  return {
46
- level: 'level3',
47
41
  id: slugid.nice(),
48
42
  add: true,
49
43
  text: element.textContent
@@ -51,7 +45,6 @@ var textRule = function textRule(element, parseChild) {
51
45
  }
52
46
  if (nodeType === 3) {
53
47
  return {
54
- level: 'level3',
55
48
  id: slugid.nice(),
56
49
  text: element.textContent
57
50
  };
@@ -102,7 +102,7 @@ var SideMenu = function SideMenu(_ref) {
102
102
  slateNode: slateNode
103
103
  })), /*#__PURE__*/React.createElement("div", {
104
104
  className: "sdoc-dropdown-menu-divider"
105
- }), [HEADER1, HEADER2, HEADER3].includes(slateNode === null || slateNode === void 0 ? void 0 : slateNode.type) && /*#__PURE__*/React.createElement(DropdownMenuItem, {
105
+ }), [HEADER1, HEADER2, HEADER3].includes(slateNode === null || slateNode === void 0 ? void 0 : slateNode.type) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
106
106
  menuConfig: {
107
107
  text: 'Copy_link_of_section',
108
108
  iconClass: 'sdocfont sdoc-link'
@@ -110,7 +110,7 @@ var SideMenu = function SideMenu(_ref) {
110
110
  onClick: onCopyHeaderLink
111
111
  }), /*#__PURE__*/React.createElement("div", {
112
112
  className: "sdoc-dropdown-menu-divider"
113
- }), /*#__PURE__*/React.createElement(DropdownMenuItem, {
113
+ })), /*#__PURE__*/React.createElement(DropdownMenuItem, {
114
114
  menuConfig: {
115
115
  text: 'Copy',
116
116
  iconClass: 'sdocfont sdoc-copy'
@@ -4,7 +4,6 @@ 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';
8
7
  import './index.css';
9
8
  var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
10
9
  var t = _ref.t;
@@ -19,7 +18,7 @@ var MoreRevisionOperations = function MoreRevisionOperations(_ref) {
19
18
  context.startRevise().then(function (res) {
20
19
  var repoID = context.getSetting('repoID');
21
20
  var siteRoot = context.getSetting('siteRoot');
22
- var revisionURL = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/?").concat(REVISION_FIRST_LOAD_KEY, "=").concat(REVISION_FIRST_LOAD_VALUE);
21
+ var revisionURL = "".concat(siteRoot, "lib/").concat(repoID, "/revisions/").concat(res.data.revision_id, "/");
23
22
  window.open(revisionURL, '_blank');
24
23
  }).catch(function (error) {
25
24
  toaster.danger(t('Error'));
@@ -41,6 +41,7 @@
41
41
  text-overflow: ellipsis;
42
42
  overflow: hidden;
43
43
  font-size: 13px;
44
+ font-weight: normal;
44
45
  }
45
46
 
46
47
  .sdoc-tag-item .sdoc-tag-added-mark {
@@ -52,10 +53,11 @@
52
53
  border-top: 1px solid #eee;
53
54
  border-bottom: none;
54
55
  overflow: hidden;
55
- text-overflow: ellipsis;
56
+ font-size: 14px;
56
57
  white-space: nowrap;
57
- background-color: #fff;
58
58
  font-weight: normal;
59
+ text-overflow: ellipsis;
60
+ background-color: #fff;
59
61
  cursor: pointer;
60
62
  }
61
63
 
@@ -203,7 +203,7 @@ var TagPopover = function TagPopover() {
203
203
  }(), [getTagList, updateTagView, t]);
204
204
  return /*#__PURE__*/React.createElement(UncontrolledPopover, {
205
205
  target: "tag-operation-icon-container",
206
- placement: "bottom-end",
206
+ placement: "bottom",
207
207
  popperClassName: "sdoc-menu-popover sdoc-dropdown-menu sdoc-tag-popover",
208
208
  trigger: "legacy",
209
209
  hideArrow: true,
@@ -2,3 +2,30 @@
2
2
  background-color: #FF8000;
3
3
  border-color: #FF8000;
4
4
  }
5
+
6
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container {
7
+ display: flex;
8
+ flex-direction: column;
9
+ align-items: center;
10
+ padding-top: 46px;
11
+ padding-bottom: 40px;
12
+ }
13
+
14
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container .sdoc-tip-img-container {
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ width: 140px;
19
+ height: 140px;
20
+ overflow: hidden;
21
+ }
22
+
23
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container .sdoc-tip-content {
24
+ width: 100%;
25
+ padding: 10px 16px 64px 16px;
26
+ text-align: center;
27
+ }
28
+
29
+ .sdoc-tip-dialog .sdoc-tip-dialog-custom-container .sdoc-tip-operation-btn {
30
+ min-width: 140px;
31
+ }
@@ -5,6 +5,7 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
5
5
  import classnames from 'classnames';
6
6
  import { TIP_TYPE, TIP_TITLE, TIP_CONTENT } from '../../constants';
7
7
  import CommonLoading from '../common-loading';
8
+ import ContentReplaced from '../../assets/images/content-replaced.png';
8
9
  import './index.css';
9
10
  var NOT_CLOSE_DIALOG_TIP_TYPE = [TIP_TYPE.HAS_BEEN_REPLACED, TIP_TYPE.HAS_BEEN_PUBLISHED, TIP_TYPE.CHECKING, TIP_TYPE.PUBLISHING];
10
11
  var TipDialog = function TipDialog(_ref) {
@@ -45,6 +46,48 @@ var TipDialog = function TipDialog(_ref) {
45
46
  };
46
47
  }
47
48
  }, [isSubmitting]);
49
+ var refreshPage = useCallback(function () {
50
+ window.location.reload();
51
+ }, []);
52
+ var renderTip = useCallback(function () {
53
+ if (tipType === TIP_TYPE.HAS_BEEN_REPLACED) {
54
+ return /*#__PURE__*/React.createElement("div", {
55
+ className: "sdoc-tip-dialog-custom-container"
56
+ }, /*#__PURE__*/React.createElement("div", {
57
+ className: "sdoc-tip-img-container"
58
+ }, /*#__PURE__*/React.createElement("img", {
59
+ src: ContentReplaced,
60
+ alt: "",
61
+ height: "140"
62
+ })), /*#__PURE__*/React.createElement("div", {
63
+ className: "sdoc-tip-content"
64
+ }, t(TIP_CONTENT[tipType])), /*#__PURE__*/React.createElement("div", {
65
+ className: "sdoc-tip-operations-container"
66
+ }, /*#__PURE__*/React.createElement(Button, {
67
+ color: "primary",
68
+ className: "highlight-bg-color sdoc-tip-operation-btn",
69
+ onClick: refreshPage
70
+ }, t('Refresh'))));
71
+ }
72
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalHeader, {
73
+ toggle: NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) ? undefined : closeDialog
74
+ }, t(TIP_TITLE[tipType])), /*#__PURE__*/React.createElement(ModalBody, {
75
+ className: "sdoc-tip-body"
76
+ }, 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, {
77
+ color: "secondary",
78
+ className: "mr-2",
79
+ onClick: closeDialog
80
+ }, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
81
+ color: "primary",
82
+ className: classnames('highlight-bg-color', {
83
+ 'd-flex align-items-center': isSubmitting
84
+ }),
85
+ disabled: isSubmitting,
86
+ onClick: onSubmit
87
+ }, isSubmitting && /*#__PURE__*/React.createElement("span", {
88
+ className: "submit-loading-container mr-2"
89
+ }, /*#__PURE__*/React.createElement(CommonLoading, null)), t('Confirm'))));
90
+ }, [children, closeDialog, isSubmitting, onSubmit, t, tipType, refreshPage]);
48
91
  return /*#__PURE__*/React.createElement(Modal, {
49
92
  isOpen: true,
50
93
  autoFocus: false,
@@ -53,23 +96,6 @@ var TipDialog = function TipDialog(_ref) {
53
96
  toggle: closeDialog,
54
97
  className: classnames('sdoc-tip-dialog', className),
55
98
  contentClassName: "sdoc-tip-modal"
56
- }, /*#__PURE__*/React.createElement(ModalHeader, {
57
- toggle: NOT_CLOSE_DIALOG_TIP_TYPE.includes(tipType) ? undefined : closeDialog
58
- }, t(TIP_TITLE[tipType])), /*#__PURE__*/React.createElement(ModalBody, {
59
- className: "sdoc-tip-body"
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, {
61
- color: "secondary",
62
- className: "mr-2",
63
- onClick: closeDialog
64
- }, t('Cancel')), /*#__PURE__*/React.createElement(Button, {
65
- color: "primary",
66
- className: classnames('highlight-bg-color', {
67
- 'd-flex align-items-center': isSubmitting
68
- }),
69
- disabled: isSubmitting,
70
- onClick: onSubmit
71
- }, isSubmitting && /*#__PURE__*/React.createElement("span", {
72
- className: "submit-loading-container mr-2"
73
- }, /*#__PURE__*/React.createElement(CommonLoading, null)), t('Confirm'))));
99
+ }, renderTip());
74
100
  };
75
101
  export default TipDialog;
@@ -2,8 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  var _TIP_TITLE, _TIP_CONTENT;
3
3
  import KeyCodes from './key-codes';
4
4
  import * as TransferTypes from './transfer-types';
5
- export var REVISION_FIRST_LOAD_KEY = 'first-load';
6
- export var REVISION_FIRST_LOAD_VALUE = '1';
7
5
  export var EXTERNAL_EVENT = {
8
6
  INTERNAL_LINK_CLICK: 'internal_link_click',
9
7
  TOGGLE_STAR: 'toggle_star',
@@ -8,7 +8,7 @@ import Layout, { Header, Content } from '../layout';
8
8
  import context from '../context';
9
9
  import ErrorBoundary from './error-boundary';
10
10
  import { PublishedRevisionDiffViewer } from '../basic-sdk';
11
- import { resetWebTitleAndURL } from '../utils';
11
+ import { resetWebTitle } from '../utils';
12
12
  import '../assets/css/simple-editor.css';
13
13
  var PublishedRevisionViewer = function PublishedRevisionViewer() {
14
14
  context.initApi();
@@ -37,7 +37,7 @@ var PublishedRevisionViewer = function PublishedRevisionViewer() {
37
37
 
38
38
  // useMount: reset title
39
39
  useEffect(function () {
40
- resetWebTitleAndURL(t);
40
+ resetWebTitle(t);
41
41
  // eslint-disable-next-line react-hooks/exhaustive-deps
42
42
  }, []);
43
43
  useEffect(function () {
@@ -10,7 +10,7 @@ import ErrorBoundary from './error-boundary';
10
10
  import { SDocEditor } from '../basic-sdk';
11
11
  import { PublishedRevisionDiffViewer, RevisionDiffViewer } from '../basic-sdk/views';
12
12
  import { useDocument } from '../hooks';
13
- import { resetWebTitleAndURL } from '../utils';
13
+ import { resetWebTitle } from '../utils';
14
14
  import '../assets/css/simple-editor.css';
15
15
  var SimpleEditor = function SimpleEditor(_ref) {
16
16
  var isStarred = _ref.isStarred,
@@ -37,7 +37,7 @@ 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');
40
+ var initIsPublished = context.getSetting('isPublished') || false;
41
41
  var _useState7 = useState(initIsPublished),
42
42
  _useState8 = _slicedToArray(_useState7, 2),
43
43
  isPublished = _useState8[0],
@@ -45,7 +45,7 @@ var SimpleEditor = function SimpleEditor(_ref) {
45
45
 
46
46
  // useMount: reset title
47
47
  useEffect(function () {
48
- resetWebTitleAndURL(t);
48
+ resetWebTitle(t);
49
49
  // eslint-disable-next-line react-hooks/exhaustive-deps
50
50
  }, []);
51
51
  var setDiffChanges = useCallback(function (diff) {
@@ -1,9 +1,6 @@
1
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
1
  import DateUtils from './date-utils';
3
2
  import LocalStorage from './local-storage-utils';
4
3
  import context from '../context';
5
- import { REVISION_FIRST_LOAD_KEY, REVISION_FIRST_LOAD_VALUE } from '../constants';
6
- import toaster from '../components/toast';
7
4
  import getEventTransfer from './get-event-transfer';
8
5
  import * as Hotkey from './hotkey';
9
6
  export var getDirPath = function getDirPath(path) {
@@ -51,39 +48,11 @@ export var isMac = function isMac() {
51
48
  return platform === 'Mac68K' || platform === 'MacPPC' || platform === 'Macintosh' || platform === 'MacIntel';
52
49
  };
53
50
  export var isMobile = typeof window !== 'undefined' && (window.innerWidth < 768 || navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null);
54
- export var resetWebTitleAndURL = function resetWebTitleAndURL(t) {
51
+ export var resetWebTitle = function resetWebTitle(t) {
55
52
  var isSdocRevision = context.getSetting('isSdocRevision');
56
53
  var originFilename = context.getSetting('originFilename');
57
54
  if (!isSdocRevision) return;
58
55
  window.document.getElementsByTagName('title')[0].innerText = "".concat(t('Revision'), " - ").concat(originFilename);
59
-
60
- // show revision created success info
61
- var url = new URL(window.location.href);
62
- var searchParams = new URLSearchParams(url.search);
63
- if (!searchParams.has(REVISION_FIRST_LOAD_KEY)) return;
64
- var firstLoadValue = searchParams.get(REVISION_FIRST_LOAD_KEY);
65
- if (firstLoadValue === REVISION_FIRST_LOAD_VALUE) {
66
- var revisionId = context.getSetting('revisionId');
67
- toaster.success(t('Revision_created', {
68
- id: revisionId
69
- }));
70
- searchParams.delete(REVISION_FIRST_LOAD_KEY);
71
- }
72
- var newParamsString = '';
73
- var _iterator = _createForOfIteratorHelper(searchParams.entries()),
74
- _step;
75
- try {
76
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
77
- var item = _step.value;
78
- newParamsString = newParamsString + "&".concat(item[0], "=").concat(item[1]);
79
- }
80
- } catch (err) {
81
- _iterator.e(err);
82
- } finally {
83
- _iterator.f();
84
- }
85
- var newURL = "".concat(url.origin).concat(url.pathname).concat(newParamsString ? '/?' + newParamsString : '');
86
- window.history.replaceState(null, null, newURL);
87
56
  };
88
57
  export var getSelectionCoords = function getSelectionCoords() {
89
58
  var doc = window.document;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -378,7 +378,7 @@
378
378
  "Keep_both_modification": "Keep both modification",
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
- "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
381
+ "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page",
382
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?",
@@ -378,7 +378,7 @@
378
378
  "Keep_both_modification": "Keep both modification",
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
- "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
381
+ "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page",
382
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?",
@@ -378,13 +378,12 @@
378
378
  "Keep_both_modification": "Keep both modification",
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
- "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
381
+ "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page",
382
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!",
386
386
  "Has_been_removed_tip": "Document has been removed, please view other documents.",
387
- "Revision_created": "Revision {{id}} created",
388
387
  "Checking": "Checking...",
389
388
  "Publishing": "Publishing...",
390
389
  "Inline": "Inline",
@@ -378,7 +378,7 @@
378
378
  "Keep_both_modification": "Keep both modification",
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
- "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
381
+ "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page",
382
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?",
@@ -378,7 +378,7 @@
378
378
  "Keep_both_modification": "Keep both modification",
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
- "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
381
+ "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page",
382
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?",
@@ -378,7 +378,7 @@
378
378
  "Keep_both_modification": "Keep both modification",
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
- "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page.",
381
+ "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page",
382
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?",
@@ -378,7 +378,7 @@
378
378
  "Keep_both_modification": "Сохранить обе модификации",
379
379
  "Tip": "Совет",
380
380
  "Rebase_delete_no_change_revision_tip": "Редакция не внесла никаких изменений по сравнению с исходным документом. Вы хотите удалить эту редакцию?",
381
- "Has_been_replaced_tip": "Содержимое документа было заменено. Обновите страницу.",
381
+ "Has_been_replaced_tip": "Document content has been replaced. Please refresh the page",
382
382
  "Has_been_published_tip": "Revision published",
383
383
  "Has_conflict_before_publish_tip": "В документе есть конфликты, разрешите их перед публикацией!",
384
384
  "Merge_tip": "В документах есть конфликты. Вы хотите объединить их?",
@@ -378,7 +378,7 @@
378
378
  "Keep_both_modification": "保留两者更改",
379
379
  "Tip": "提示",
380
380
  "Rebase_delete_no_change_revision_tip": "修订改没有更改,是否删除修订稿?",
381
- "Has_been_replaced_tip": "文档内容已经被替换,请刷新页面。",
381
+ "Has_been_replaced_tip": "文档内容已经被替换,请刷新页面",
382
382
  "Has_been_published_tip": "修订稿已发布",
383
383
  "Has_conflict_before_publish_tip": "文档有冲突,请解决冲突后再发布!",
384
384
  "Merge_tip": "文档有冲突,是否合并?",