@seafile/seafile-editor 0.3.99 → 0.3.100

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 (90) hide show
  1. package/dist/_i18n/index.js +20 -0
  2. package/dist/assets/css/comment-dialog.css +50 -0
  3. package/dist/{css → assets/css}/diff-viewer.css +0 -0
  4. package/dist/{css/richeditor → assets/css}/formula.css +0 -0
  5. package/dist/{css → assets/css}/history-viewer.css +0 -0
  6. package/dist/{css/richeditor → assets/css}/image.css +0 -0
  7. package/dist/{index.css → assets/css/index.css} +0 -0
  8. package/dist/assets/css/issue-card.css +43 -0
  9. package/dist/{css → assets/css}/keyboard-shortcuts.css +0 -0
  10. package/dist/{css/richeditor → assets/css}/link.css +0 -0
  11. package/dist/{css/plaineditor → assets/css}/markdown-editor.css +0 -0
  12. package/dist/{css → assets/css}/markdown-viewer.css +0 -0
  13. package/dist/{css/richeditor → assets/css}/navbar-imgbutton.css +0 -0
  14. package/dist/assets/css/outline.css +29 -0
  15. package/dist/{css/richeditor → assets/css}/table.css +0 -0
  16. package/dist/{css/richeditor → assets/css}/textlink-hovermenu.css +0 -0
  17. package/dist/{css → assets/css}/topbar.css +19 -33
  18. package/dist/{css/richeditor → assets/css}/tree-view.css +0 -0
  19. package/dist/{css/richeditor/right-panel.css → assets/css/user-help.css} +9 -9
  20. package/dist/assets/editor/plain-editor.css +30 -0
  21. package/dist/assets/editor/rich-editor.css +104 -0
  22. package/dist/assets/editor/simple-editor.css +77 -0
  23. package/dist/{css/richeditor → assets/rich-editor}/document-info.css +0 -0
  24. package/dist/components/add-formula-dialog.js +6 -4
  25. package/dist/components/add-image-dialog.js +3 -1
  26. package/dist/components/add-link-dialog.js +4 -3
  27. package/dist/components/comment-dialog.js +12 -6
  28. package/dist/components/markdown-lint.js +1 -0
  29. package/dist/components/outline/index.js +97 -0
  30. package/dist/components/outline/outline-item.js +70 -0
  31. package/dist/components/shortcut-dialog.js +1 -1
  32. package/dist/components/{topbar-component → toolbar}/header-list.js +0 -0
  33. package/dist/components/toolbar/help-group.js +40 -0
  34. package/dist/components/toolbar/index.js +4 -0
  35. package/dist/components/{topbar-component/upload-img.js → toolbar/insert-image.js} +18 -15
  36. package/dist/components/toolbar/insert-table.js +155 -0
  37. package/dist/components/toolbar/table-group.js +82 -0
  38. package/dist/components/{toolbar.js → toolbar/toolbar.js} +102 -64
  39. package/dist/components/{topbar-component → toolbar/widgets}/button-group.js +0 -0
  40. package/dist/components/toolbar/widgets/button-item.js +144 -0
  41. package/dist/components/toolbar/widgets/drop-list.js +101 -0
  42. package/dist/components/user-help.js +16 -10
  43. package/dist/editor/controller/block-element-controller.js +6 -2
  44. package/dist/editor/controller/inline-element-controller.js +6 -2
  45. package/dist/editor/editor-builder.js +107 -0
  46. package/dist/editor/editor-component/formula.js +4 -2
  47. package/dist/editor/editor-component/image.js +10 -6
  48. package/dist/editor/editor-component/table.js +1 -1
  49. package/dist/editor/editor-plugin.js +3 -1
  50. package/dist/editor/editor.js +1 -32
  51. package/dist/editor/index.js +97 -0
  52. package/dist/editor/markdown-editor.js +323 -0
  53. package/dist/editor/plain-markdown-editor.js +5 -4
  54. package/dist/editor/rich-markdown-editor.js +70 -149
  55. package/dist/editor/simple-editor.js +44 -78
  56. package/dist/{css/richeditor → example/assets/css}/comments-list.css +0 -45
  57. package/dist/{css/richeditor → example/assets/css}/detail-list-view.css +0 -0
  58. package/dist/{css/richeditor → example/assets/css}/participants-list.css +0 -0
  59. package/dist/{css → example/assets/css}/react-mentions-default-style.js +0 -0
  60. package/dist/example/assets/css/seafile-editor-main.css +125 -0
  61. package/dist/example/assets/css/seafile-editor-side.css +89 -0
  62. package/dist/example/assets/css/side-panel.css +81 -0
  63. package/dist/{components → example/components}/comment-panel.js +12 -6
  64. package/dist/{components → example/components}/detail-list-view.js +1 -1
  65. package/dist/{components → example/components}/participants-list.js +1 -1
  66. package/dist/{components → example/components}/side-panel.js +5 -7
  67. package/dist/example/seafile-editor.js +137 -0
  68. package/dist/index.js +9 -0
  69. package/dist/index.local.js +58 -0
  70. package/dist/pages/seafile-editor/index.js +38 -0
  71. package/dist/{editor → pages/seafile-editor}/seafile-editor.js +19 -35
  72. package/dist/{seafile-editor-chooser.js → pages/seafile-editor-chooser.js} +0 -0
  73. package/dist/{seafile-markdown-editor.js → pages/seafile-markdown-editor.js} +5 -5
  74. package/dist/{seafile-markdown-viewer.js → pages/seafile-markdown-viewer.js} +3 -3
  75. package/dist/{seafile-simple-editor.js → pages/seafile-simple-editor.js} +5 -2
  76. package/dist/viewer/diff-viewer.js +1 -1
  77. package/dist/viewer/markdown-viewer.js +14 -15
  78. package/dist/viewer/slate-viewer.js +9 -24
  79. package/dist/viewer/viewer-formula.js +1 -1
  80. package/package.json +5 -13
  81. package/dist/components/generate-share-link.js +0 -412
  82. package/dist/components/internal-link-dialog.js +0 -96
  83. package/dist/components/outline.js +0 -130
  84. package/dist/components/topbar-component/icon-button.js +0 -99
  85. package/dist/components/topbar-component/insert-file.js +0 -67
  86. package/dist/components/topbar-component/table-toolbar.js +0 -175
  87. package/dist/css/layout.css +0 -111
  88. package/dist/css/markdown-viewer-slate/file-tags-list.css +0 -76
  89. package/dist/css/richeditor/rich-editor-main.css +0 -32
  90. package/dist/css/richeditor/side-panel.css +0 -183
@@ -1,59 +1,94 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
3
4
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
- import React from 'react';
6
- import HeaderList from '../components/topbar-component/header-list';
7
- import ButtonGroup from '../components/topbar-component/button-group';
8
- import IconButton from '../components/topbar-component/icon-button';
9
- import TableButton from '../components/table-button';
6
+ import React, { Fragment } from 'react';
10
7
  import { withTranslation } from 'react-i18next';
11
- import AddLinkDialog from './add-link-dialog';
12
- import AddImageDialog from './add-image-dialog';
13
- import AddFormulaDialog from './add-formula-dialog';
14
- import TableToolBar from './topbar-component/table-toolbar';
15
- import { EditorUtils } from '../editor/editor-utils/common-editor-utils';
16
- import UploadImg from './topbar-component/upload-img'; // import InsertFile from './topbarcomponent/insertFile';
8
+ import ButtonItem from './widgets/button-item';
9
+ import ButtonGroup from './widgets/button-group';
10
+ import HeaderList from './header-list';
11
+ import InsertTable from './insert-table';
12
+ import InsertImage from './insert-image';
13
+ import TableGroup from './table-group';
14
+ import AddLinkDialog from '../add-link-dialog';
15
+ import AddImageDialog from '../add-image-dialog';
16
+ import AddFormulaDialog from '../add-formula-dialog';
17
+ import EditorBuilder from '../../editor/editor-builder';
18
+ import '../../assets/css/topbar.css';
17
19
 
18
- var ToolBar = /*#__PURE__*/function (_React$Component) {
19
- _inherits(ToolBar, _React$Component);
20
+ var Toolbar = /*#__PURE__*/function (_React$Component) {
21
+ _inherits(Toolbar, _React$Component);
20
22
 
21
- var _super = _createSuper(ToolBar);
23
+ var _super = _createSuper(Toolbar);
22
24
 
23
- function ToolBar(props) {
25
+ function Toolbar(props) {
24
26
  var _this;
25
27
 
26
- _classCallCheck(this, ToolBar);
28
+ _classCallCheck(this, Toolbar);
27
29
 
28
30
  _this = _super.call(this, props);
29
31
 
32
+ _this.onToggleLinkDialog = function () {
33
+ _this.setState({
34
+ isShowLinkDialog: !_this.state.isShowLinkDialog
35
+ });
36
+ };
37
+
30
38
  _this.onToggleLink = function (event) {
31
39
  event.preventDefault();
32
40
 
33
41
  var isLinkActive = _this.editorUtils.isLinkActive();
34
42
 
35
43
  if (!isLinkActive) {
36
- _this.props.onToggleLinkDialog();
44
+ _this.setState({
45
+ isShowLinkDialog: !_this.state.isShowLinkDialog
46
+ });
37
47
 
38
48
  return;
39
- } else {
40
- _this.editorUtils.unwrapLink();
41
49
  }
50
+
51
+ _this.editorUtils.unwrapLink();
42
52
  };
43
53
 
44
- _this.editor = window.editor;
45
- _this.editorUtils = new EditorUtils(_this.editor);
54
+ _this.onToggleLinkDialog = function () {
55
+ _this.setState({
56
+ isShowLinkDialog: !_this.state.isShowLinkDialog
57
+ });
58
+ };
59
+
60
+ _this.onToggleFormulaDialog = function () {
61
+ _this.setState({
62
+ isShowFormulaDialog: !_this.state.isShowFormulaDialog
63
+ });
64
+ };
65
+
66
+ _this.onToggleImageDialog = function () {
67
+ _this.setState({
68
+ isShowImageDialog: !_this.state.isShowImageDialog
69
+ });
70
+ };
71
+
72
+ _this.state = {
73
+ isShowLinkDialog: false,
74
+ isShowImageDialog: false,
75
+ isShowFormulaDialog: false
76
+ };
77
+ _this.editorUtils = EditorBuilder.getEditorUtils();
78
+ window.abcdef_editorToolbar = _assertThisInitialized(_this);
46
79
  return _this;
47
80
  }
48
81
 
49
- _createClass(ToolBar, [{
82
+ _createClass(Toolbar, [{
50
83
  key: "render",
51
84
  value: function render() {
52
85
  var _this2 = this;
53
86
 
54
- var t = this.props.t;
55
- var toolbarStatus = this.props.toolbarStatus;
56
- var readOnly = this.props.readOnly;
87
+ var _this$props = this.props,
88
+ hasSidePanel = _this$props.hasSidePanel,
89
+ isShowSidePanel = _this$props.isShowSidePanel,
90
+ t = _this$props.t;
91
+ var toolbarStatus = this.editorUtils.getToolbarStatus();
57
92
  var isTableActive = toolbarStatus.isTableActive,
58
93
  isHeadActive = toolbarStatus.isHeadActive,
59
94
  isCodeActive = toolbarStatus.isCodeActive,
@@ -67,11 +102,16 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
67
102
  isCheckListActive = toolbarStatus.isCheckListActive,
68
103
  isFormulaActive = toolbarStatus.isFormulaActive;
69
104
  var isListActive = isOrderedListActive || isUnorderedListActive || isCheckListActive;
70
- return /*#__PURE__*/React.createElement("div", {
71
- className: 'sf-editor-rich-menu ' + (this.props.isSimpleEditor ? '' : 'rich-menu')
105
+ var sidePanelText = isShowSidePanel ? t('Hide_side_panel') : t('Show_side_panel');
106
+ var _this$state = this.state,
107
+ isShowLinkDialog = _this$state.isShowLinkDialog,
108
+ isShowImageDialog = _this$state.isShowImageDialog,
109
+ isShowFormulaDialog = _this$state.isShowFormulaDialog;
110
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
111
+ className: 'sf-editor-toolbar ' + (this.props.isSimpleEditor ? '' : 'rich-menu')
72
112
  }, /*#__PURE__*/React.createElement("div", {
73
113
  className: 'button-container'
74
- }, !readOnly && /*#__PURE__*/React.createElement("div", {
114
+ }, /*#__PURE__*/React.createElement("div", {
75
115
  className: 'header-list-container'
76
116
  }, /*#__PURE__*/React.createElement(HeaderList, {
77
117
  disabled: isFormulaActive || isCodeActive || isTableActive,
@@ -79,7 +119,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
79
119
  onClickHeader: this.editorUtils.onClickHeader
80
120
  })), /*#__PURE__*/React.createElement(ButtonGroup, {
81
121
  className: 'editor-btn-group'
82
- }, /*#__PURE__*/React.createElement(IconButton, {
122
+ }, /*#__PURE__*/React.createElement(ButtonItem, {
83
123
  disabled: isFormulaActive || isCodeActive || isHeadActive,
84
124
  isRichEditor: true,
85
125
  text: t('bold'),
@@ -89,7 +129,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
89
129
  onMouseDown: function onMouseDown(event) {
90
130
  return _this2.editorUtils.onClickMark(event, 'BOLD');
91
131
  }
92
- }), /*#__PURE__*/React.createElement(IconButton, {
132
+ }), /*#__PURE__*/React.createElement(ButtonItem, {
93
133
  disabled: isFormulaActive || isCodeActive || isHeadActive,
94
134
  isRichEditor: true,
95
135
  text: t('italic'),
@@ -99,7 +139,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
99
139
  onMouseDown: function onMouseDown(event) {
100
140
  return _this2.editorUtils.onClickMark(event, 'ITALIC');
101
141
  }
102
- }), /*#__PURE__*/React.createElement(IconButton, {
142
+ }), /*#__PURE__*/React.createElement(ButtonItem, {
103
143
  disabled: isFormulaActive || isCodeActive || isHeadActive,
104
144
  isRichEditor: true,
105
145
  text: t('code'),
@@ -109,7 +149,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
109
149
  onMouseDown: function onMouseDown(event) {
110
150
  return _this2.editorUtils.onClickMark(event, 'CODE');
111
151
  }
112
- }), /*#__PURE__*/React.createElement(IconButton, {
152
+ }), /*#__PURE__*/React.createElement(ButtonItem, {
113
153
  disabled: isFormulaActive || isCodeActive || isHeadActive,
114
154
  isRichEditor: true,
115
155
  text: t('insert_link'),
@@ -119,7 +159,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
119
159
  onMouseDown: this.onToggleLink
120
160
  })), /*#__PURE__*/React.createElement(ButtonGroup, {
121
161
  className: 'editor-btn-group'
122
- }, /*#__PURE__*/React.createElement(IconButton, {
162
+ }, /*#__PURE__*/React.createElement(ButtonItem, {
123
163
  disabled: isFormulaActive || isTableActive || isCodeActive || isHeadActive,
124
164
  isRichEditor: true,
125
165
  text: t('quote'),
@@ -129,7 +169,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
129
169
  onMouseDown: function onMouseDown(event) {
130
170
  return _this2.editorUtils.onClickBlock(event, 'blockquote');
131
171
  }
132
- }), /*#__PURE__*/React.createElement(IconButton, {
172
+ }), /*#__PURE__*/React.createElement(ButtonItem, {
133
173
  disabled: isFormulaActive || isTableActive || isCodeActive || isHeadActive,
134
174
  isRichEditor: true,
135
175
  text: t('ordered_list'),
@@ -139,7 +179,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
139
179
  onMouseDown: function onMouseDown(event) {
140
180
  return _this2.editorUtils.onClickBlock(event, 'ordered_list');
141
181
  }
142
- }), /*#__PURE__*/React.createElement(IconButton, {
182
+ }), /*#__PURE__*/React.createElement(ButtonItem, {
143
183
  disabled: isFormulaActive || isTableActive || isCodeActive || isHeadActive,
144
184
  isRichEditor: true,
145
185
  text: t('unordered_list'),
@@ -149,7 +189,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
149
189
  onMouseDown: function onMouseDown(event) {
150
190
  return _this2.editorUtils.onClickBlock(event, 'unordered_list');
151
191
  }
152
- }), /*#__PURE__*/React.createElement(IconButton, {
192
+ }), /*#__PURE__*/React.createElement(ButtonItem, {
153
193
  disabled: isFormulaActive || isTableActive || isCodeActive || isHeadActive,
154
194
  isRichEditor: true,
155
195
  text: t('check_list_item'),
@@ -159,7 +199,7 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
159
199
  onMouseDown: this.editorUtils.onToggleCheckItem
160
200
  })), /*#__PURE__*/React.createElement(ButtonGroup, {
161
201
  className: 'editor-btn-group'
162
- }, /*#__PURE__*/React.createElement(IconButton, {
202
+ }, /*#__PURE__*/React.createElement(ButtonItem, {
163
203
  disabled: isFormulaActive || isTableActive || isHeadActive,
164
204
  isRichEditor: true,
165
205
  text: t('code_block'),
@@ -168,31 +208,30 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
168
208
  onMouseDown: function onMouseDown(event) {
169
209
  return _this2.editorUtils.onClickBlock(event, 'code_block');
170
210
  },
171
- isActive: isCodeActive && !readOnly
172
- }), /*#__PURE__*/React.createElement(TableButton, {
211
+ isActive: isCodeActive
212
+ }), /*#__PURE__*/React.createElement(InsertTable, {
173
213
  disabled: isFormulaActive || isCodeActive || isTableActive || isHeadActive,
174
214
  isRichEditor: true,
175
215
  text: t('insert_table'),
176
216
  id: 'tableButton',
177
217
  icon: 'iconfont icon-table',
178
218
  onAddTable: this.editorUtils.onAddTable
179
- }), window.canInsertFormula && /*#__PURE__*/React.createElement(IconButton, {
219
+ }), window.canInsertFormula && /*#__PURE__*/React.createElement(ButtonItem, {
180
220
  disabled: isFormulaActive || isCodeActive || isTableActive || isHeadActive || isListActive,
181
221
  isRichEditor: true,
182
222
  text: t('insert_formula'),
183
223
  id: 'formulaButton',
184
224
  icon: 'iconfont icon-formula',
185
- onMouseDown: this.props.onToggleFormulaDialog
186
- }), /*#__PURE__*/React.createElement(UploadImg, {
225
+ onMouseDown: this.onToggleFormulaDialog
226
+ }), /*#__PURE__*/React.createElement(InsertImage, {
187
227
  disabled: isFormulaActive || isCodeActive || isHeadActive,
188
228
  text: 'insert_image',
189
229
  id: 'insertImageButton',
190
230
  insertRepoFile: this.props.insertRepoFile,
191
- isSimpleEditor: this.props.isSimpleEditor,
192
231
  onInsertImage: this.editorUtils.insertImage,
193
232
  toolbarStatus: this.props.toolbarStatus,
194
- onToggleImageDialog: this.props.onToggleImageDialog
195
- })), isTableActive && !readOnly && /*#__PURE__*/React.createElement(TableToolBar, {
233
+ onToggleImageDialog: this.onToggleImageDialog
234
+ })), isTableActive && /*#__PURE__*/React.createElement(TableGroup, {
196
235
  onRemoveTable: this.editorUtils.onRemoveTable,
197
236
  onInsertColumn: this.editorUtils.onInsertColumn,
198
237
  onRemoveColumn: this.editorUtils.onRemoveColumn,
@@ -201,46 +240,45 @@ var ToolBar = /*#__PURE__*/function (_React$Component) {
201
240
  onSetAlign: this.editorUtils.onSetAlign
202
241
  }), /*#__PURE__*/React.createElement(ButtonGroup, {
203
242
  className: 'editor-btn-group'
204
- }, /*#__PURE__*/React.createElement(IconButton, {
243
+ }, /*#__PURE__*/React.createElement(ButtonItem, {
205
244
  className: 'editor-clear-format',
206
245
  isRichEditor: true,
207
246
  text: t('Clear_format'),
208
247
  id: 'clearButton',
209
248
  icon: 'iconfont icon-clear-format',
210
- onMouseDown: this.editorUtils.clearFormat,
211
- isActive: readOnly
212
- }))), this.props.hasSidePanel && /*#__PURE__*/React.createElement("div", {
249
+ onMouseDown: this.editorUtils.clearFormat
250
+ }))), hasSidePanel && /*#__PURE__*/React.createElement("div", {
213
251
  className: "button-container"
214
252
  }, !this.props.isShowSidePanel && /*#__PURE__*/React.createElement(ButtonGroup, {
215
253
  className: "editor-btn-group position-absolute dropdown-menu-right"
216
- }, /*#__PURE__*/React.createElement(IconButton, {
254
+ }, /*#__PURE__*/React.createElement(ButtonItem, {
217
255
  isRichEditor: true,
218
- text: t('Show_side_panel'),
219
- id: "showSidepanel",
256
+ text: sidePanelText,
257
+ id: "showSidePanel",
220
258
  icon: "iconfont icon-angle-double-left",
221
259
  isActive: false,
222
260
  onMouseDown: this.props.toggleSidePanel
223
261
  })), this.props.isShowSidePanel && /*#__PURE__*/React.createElement(ButtonGroup, {
224
262
  className: "editor-btn-group position-absolute dropdown-menu-right"
225
- }, /*#__PURE__*/React.createElement(IconButton, {
263
+ }, /*#__PURE__*/React.createElement(ButtonItem, {
226
264
  isRichEditor: true,
227
- text: t('Hide_side_panel'),
228
- id: "hideSidepanel",
265
+ text: sidePanelText,
266
+ id: "hideSidePanel",
229
267
  icon: "iconfont icon-angle-double-right",
230
268
  isActive: false,
231
269
  onMouseDown: this.props.toggleSidePanel
232
- }))), this.props.isShowLinkDialog && /*#__PURE__*/React.createElement(AddLinkDialog, {
233
- toggleLinkDialog: this.props.onToggleLinkDialog
234
- }), this.props.isShowFormulaDialog && /*#__PURE__*/React.createElement(AddFormulaDialog, {
235
- toggleFormulaDialog: this.props.onToggleFormulaDialog
236
- }), this.props.isShowImageDialog && /*#__PURE__*/React.createElement(AddImageDialog, {
237
- onToggleImageDialog: this.props.onToggleImageDialog,
238
- insertImage: this.editorUtils.insertImage
270
+ })))), isShowLinkDialog && /*#__PURE__*/React.createElement(AddLinkDialog, {
271
+ toggleLinkDialog: this.onToggleLinkDialog
272
+ }), isShowFormulaDialog && /*#__PURE__*/React.createElement(AddFormulaDialog, {
273
+ toggleFormulaDialog: this.onToggleFormulaDialog
274
+ }), isShowImageDialog && /*#__PURE__*/React.createElement(AddImageDialog, {
275
+ insertImage: this.editorUtils.insertImage,
276
+ onToggleImageDialog: this.onToggleImageDialog
239
277
  }));
240
278
  }
241
279
  }]);
242
280
 
243
- return ToolBar;
281
+ return Toolbar;
244
282
  }(React.Component);
245
283
 
246
- export default withTranslation('seafile-editor')(ToolBar);
284
+ export default withTranslation('seafile-editor')(Toolbar);
@@ -0,0 +1,144 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import { Tooltip } from 'reactstrap';
7
+ import { withTranslation } from 'react-i18next';
8
+
9
+ var ButtonItem = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(ButtonItem, _React$Component);
11
+
12
+ var _super = _createSuper(ButtonItem);
13
+
14
+ function ButtonItem(props) {
15
+ var _this;
16
+
17
+ _classCallCheck(this, ButtonItem);
18
+
19
+ _this = _super.call(this, props);
20
+
21
+ _this.toggle = function () {
22
+ var disabled = _this.props.disabled;
23
+ if (disabled) return;
24
+ var _this$state = _this.state,
25
+ isFreezed = _this$state.isFreezed,
26
+ tooltipOpen = _this$state.tooltipOpen;
27
+ if (isFreezed && !tooltipOpen) return;
28
+
29
+ _this.setState({
30
+ tooltipOpen: !tooltipOpen,
31
+ isFreezed: true
32
+ });
33
+
34
+ _this.timer = setTimeout(function () {
35
+ _this.setState({
36
+ isFreezed: false
37
+ });
38
+ }, 100);
39
+ };
40
+
41
+ _this.onClick = function (event) {
42
+ if (!_this.props.disabled) {
43
+ _this.props.onClick && _this.props.onClick(event);
44
+ }
45
+ };
46
+
47
+ _this.onMouseDown = function (event) {
48
+ if (!_this.props.disabled) {
49
+ _this.props.onMouseDown(event);
50
+ }
51
+ };
52
+
53
+ _this.getClassName = function () {
54
+ var _this$props = _this.props,
55
+ isRichEditor = _this$props.isRichEditor,
56
+ className = _this$props.className,
57
+ disabled = _this$props.disabled;
58
+ var itemClass = 'btn btn-icon btn-secondary btn-active';
59
+ if (!isRichEditor) return itemClass + ' ' + className;
60
+ itemClass = "rich-icon-btn ".concat(disabled ? 'rich-icon-btn-disabled' : 'rich-icon-btn-hover');
61
+ return itemClass + ' ' + className;
62
+ };
63
+
64
+ _this.state = {
65
+ tooltipOpen: false,
66
+ isFreezed: false
67
+ };
68
+ return _this;
69
+ }
70
+
71
+ _createClass(ButtonItem, [{
72
+ key: "componentWillUnmount",
73
+ value: function componentWillUnmount() {
74
+ this.timer && clearTimeout(this.timer);
75
+ }
76
+ }, {
77
+ key: "shouldComponentUpdate",
78
+ value: function shouldComponentUpdate(nextProps, nextState) {
79
+ var disabled = nextProps.disabled,
80
+ isActive = nextProps.isActive;
81
+ var _this$props2 = this.props,
82
+ oldDisabled = _this$props2.disabled,
83
+ oldIsActive = _this$props2.isActive;
84
+
85
+ if (disabled !== oldDisabled) {
86
+ this.setState({
87
+ tooltipOpen: false
88
+ });
89
+ return true;
90
+ } // only render iconButton when the button is active or show show tooltip
91
+
92
+
93
+ var tooltipOpen = nextState.tooltipOpen;
94
+ var oldTooltipOpen = this.state.tooltipOpen;
95
+
96
+ if (tooltipOpen === oldTooltipOpen && isActive === oldIsActive) {
97
+ return false;
98
+ }
99
+
100
+ return true;
101
+ }
102
+ }, {
103
+ key: "render",
104
+ value: function render() {
105
+ var tooltipOpen = this.state.tooltipOpen;
106
+ var _this$props3 = this.props,
107
+ id = _this$props3.id,
108
+ isActive = _this$props3.isActive,
109
+ disabled = _this$props3.disabled,
110
+ icon = _this$props3.icon,
111
+ text = _this$props3.text;
112
+ var className = this.getClassName();
113
+ var delay = {
114
+ show: 0,
115
+ hide: 0
116
+ };
117
+ return /*#__PURE__*/React.createElement("button", {
118
+ type: "button",
119
+ id: id,
120
+ className: className,
121
+ "data-active": isActive,
122
+ disabled: disabled,
123
+ onClick: this.onClick,
124
+ onMouseDown: this.onMouseDown
125
+ }, /*#__PURE__*/React.createElement("i", {
126
+ className: icon
127
+ }), /*#__PURE__*/React.createElement(Tooltip, {
128
+ target: id,
129
+ isOpen: tooltipOpen,
130
+ delay: delay,
131
+ placement: "bottom",
132
+ toggle: this.toggle
133
+ }, text));
134
+ }
135
+ }]);
136
+
137
+ return ButtonItem;
138
+ }(React.Component);
139
+
140
+ ButtonItem.defaultProps = {
141
+ className: '',
142
+ isActive: false
143
+ };
144
+ export default withTranslation('seafile-editor')(ButtonItem);
@@ -0,0 +1,101 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import ReactDOM from 'react-dom';
7
+
8
+ var DropList = /*#__PURE__*/function (_React$PureComponent) {
9
+ _inherits(DropList, _React$PureComponent);
10
+
11
+ var _super = _createSuper(DropList);
12
+
13
+ function DropList(props) {
14
+ var _this;
15
+
16
+ _classCallCheck(this, DropList);
17
+
18
+ _this = _super.call(this, props);
19
+
20
+ _this.handleClick = function (event) {
21
+ if (_this.props.disabled) return;
22
+
23
+ var container = _this.getContainer();
24
+
25
+ if (container.contains(event.target)) {
26
+ _this.toggle();
27
+ } else {
28
+ if (_this.state.dropdownOpen) {
29
+ _this.setState({
30
+ dropdownOpen: !_this.state.dropdownOpen
31
+ });
32
+ }
33
+ }
34
+ };
35
+
36
+ _this.toggle = function () {
37
+ _this.setState({
38
+ dropdownOpen: !_this.state.dropdownOpen
39
+ });
40
+ };
41
+
42
+ _this.state = {
43
+ dropdownOpen: false
44
+ };
45
+ return _this;
46
+ }
47
+
48
+ _createClass(DropList, [{
49
+ key: "getContainer",
50
+ value: function getContainer() {
51
+ return ReactDOM.findDOMNode(this);
52
+ }
53
+ }, {
54
+ key: "componentDidMount",
55
+ value: function componentDidMount() {
56
+ document.addEventListener('click', this.handleClick);
57
+ }
58
+ }, {
59
+ key: "componentWillUnmount",
60
+ value: function componentWillUnmount() {
61
+ document.removeEventListener('click', this.handleClick);
62
+ }
63
+ }, {
64
+ key: "render",
65
+ value: function render() {
66
+ var items = [];
67
+ this.props.items.forEach(function (item, index) {
68
+ items.push( /*#__PURE__*/React.createElement("button", {
69
+ key: 'dropdown-item' + index,
70
+ onMouseDown: item.handle,
71
+ className: 'dropdown-item'
72
+ }, item.icon ? /*#__PURE__*/React.createElement("i", {
73
+ className: item.icon,
74
+ style: {
75
+ marginRight: '6px'
76
+ }
77
+ }) : null, item.text));
78
+ });
79
+ return /*#__PURE__*/React.createElement("div", {
80
+ className: 'custom-dropdown-list'
81
+ }, /*#__PURE__*/React.createElement("div", {
82
+ id: 'list_toggle',
83
+ className: 'dropdown-list-toggle'
84
+ }, /*#__PURE__*/React.createElement("i", {
85
+ className: this.props.icon,
86
+ style: {
87
+ marginRight: '3px'
88
+ }
89
+ }), /*#__PURE__*/React.createElement("i", {
90
+ className: this.state.dropdownOpen ? 'iconfont icon-caret-up' : 'iconfont icon-drop-down'
91
+ })), this.state.dropdownOpen && /*#__PURE__*/React.createElement("div", {
92
+ role: 'menu',
93
+ className: 'custom-dropdown-menu dropdown-menu'
94
+ }, items));
95
+ }
96
+ }]);
97
+
98
+ return DropList;
99
+ }(React.PureComponent);
100
+
101
+ export default DropList;
@@ -3,6 +3,8 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
+ import { withTranslation } from 'react-i18next';
7
+ import '../assets/css/user-help.css';
6
8
 
7
9
  var ShortCut = /*#__PURE__*/function (_React$Component) {
8
10
  _inherits(ShortCut, _React$Component);
@@ -162,34 +164,38 @@ var HelpShortcutList = /*#__PURE__*/function (_React$PureComponent2) {
162
164
  return HelpShortcutList;
163
165
  }(React.PureComponent);
164
166
 
165
- var UserHelpDialog = /*#__PURE__*/function (_React$PureComponent3) {
166
- _inherits(UserHelpDialog, _React$PureComponent3);
167
+ var UserHelp = /*#__PURE__*/function (_React$PureComponent3) {
168
+ _inherits(UserHelp, _React$PureComponent3);
167
169
 
168
- var _super4 = _createSuper(UserHelpDialog);
170
+ var _super4 = _createSuper(UserHelp);
169
171
 
170
- function UserHelpDialog() {
171
- _classCallCheck(this, UserHelpDialog);
172
+ function UserHelp() {
173
+ _classCallCheck(this, UserHelp);
172
174
 
173
175
  return _super4.apply(this, arguments);
174
176
  }
175
177
 
176
- _createClass(UserHelpDialog, [{
178
+ _createClass(UserHelp, [{
177
179
  key: "render",
178
180
  value: function render() {
181
+ var t = this.props.t;
182
+ var userHelp = t('userHelp', {
183
+ returnObjects: true
184
+ });
179
185
  return /*#__PURE__*/React.createElement("div", {
180
186
  className: 'seafile-editor-help align-self-end'
181
187
  }, /*#__PURE__*/React.createElement("div", {
182
188
  className: 'help-header d-flex'
183
189
  }, /*#__PURE__*/React.createElement("div", {
184
190
  className: 'help-title'
185
- }, this.props.userHelp.title), /*#__PURE__*/React.createElement("div", {
191
+ }, userHelp.title), /*#__PURE__*/React.createElement("div", {
186
192
  className: 'help-close',
187
193
  onClick: this.props.hideHelpDialog
188
194
  }, /*#__PURE__*/React.createElement("i", {
189
195
  className: 'iconfont icon-times-circle'
190
196
  }))), /*#__PURE__*/React.createElement("div", {
191
197
  className: 'help-content'
192
- }, this.props.userHelp.userHelpData.map(function (item, index) {
198
+ }, userHelp.userHelpData.map(function (item, index) {
193
199
  return /*#__PURE__*/React.createElement(HelpShortcutList, {
194
200
  key: 'help-list' + index,
195
201
  index: index,
@@ -199,7 +205,7 @@ var UserHelpDialog = /*#__PURE__*/function (_React$PureComponent3) {
199
205
  }
200
206
  }]);
201
207
 
202
- return UserHelpDialog;
208
+ return UserHelp;
203
209
  }(React.PureComponent);
204
210
 
205
- export default UserHelpDialog;
211
+ export default withTranslation('seafile-editor')(UserHelp);
@@ -14,6 +14,7 @@ import generateLinkElement from '../element-model/link';
14
14
  import generateImageElement from '../element-model/image';
15
15
  import isUrl from 'is-url';
16
16
  import { SfEditor } from '../custom/custom';
17
+ import EditorBuilder from '../editor-builder';
17
18
 
18
19
  var withBlock = function withBlock(editor) {
19
20
  var exec = editor.exec;
@@ -58,7 +59,10 @@ var withBlock = function withBlock(editor) {
58
59
  return;
59
60
  }
60
61
 
61
- if (window.editor.editorApi.isInternalFileLink(text)) {
62
+ var _EditorBuilder$getEdi = EditorBuilder.getEditor(),
63
+ editorApi = _EditorBuilder$getEdi.editorApi;
64
+
65
+ if (editorApi.isInternalFileLink(text)) {
62
66
  var index = text.lastIndexOf('/');
63
67
 
64
68
  if (index > 0) {
@@ -78,7 +82,7 @@ var withBlock = function withBlock(editor) {
78
82
  }
79
83
  }
80
84
 
81
- if (window.editor.editorApi.isInternalDirLink(text)) {
85
+ if (editorApi.isInternalDirLink(text)) {
82
86
  var _index = text.lastIndexOf('/');
83
87
 
84
88
  if (_index > 0) {