@seafile/seafile-editor 0.3.99 → 0.3.102

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 (85) hide show
  1. package/README.md +42 -110
  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/assets/css/issue-card.css +43 -0
  8. package/dist/{css → assets/css}/keyboard-shortcuts.css +0 -0
  9. package/dist/{css/richeditor → assets/css}/link.css +0 -0
  10. package/dist/{css/plaineditor → assets/css}/markdown-editor.css +0 -0
  11. package/dist/{css → assets/css}/markdown-viewer.css +0 -0
  12. package/dist/{css/richeditor → assets/css}/navbar-imgbutton.css +0 -0
  13. package/dist/assets/css/outline.css +29 -0
  14. package/dist/{css/richeditor → assets/css}/table.css +0 -0
  15. package/dist/{css/richeditor → assets/css}/textlink-hovermenu.css +0 -0
  16. package/dist/{css → assets/css}/topbar.css +38 -146
  17. package/dist/{css/richeditor → assets/css}/tree-view.css +0 -0
  18. package/dist/{css/richeditor/right-panel.css → assets/css/user-help.css} +9 -9
  19. package/dist/assets/editor/plain-editor.css +30 -0
  20. package/dist/assets/editor/simple-editor.css +77 -0
  21. package/dist/components/add-formula-dialog.js +6 -4
  22. package/dist/components/add-image-dialog.js +3 -1
  23. package/dist/components/add-link-dialog.js +4 -3
  24. package/dist/components/comment-dialog.js +12 -6
  25. package/dist/components/markdown-lint.js +1 -0
  26. package/dist/components/outline/index.js +104 -0
  27. package/dist/components/outline/outline-item.js +70 -0
  28. package/dist/components/shortcut-dialog.js +1 -1
  29. package/dist/components/{topbar-component → toolbar}/header-list.js +0 -0
  30. package/dist/components/toolbar/help-group.js +40 -0
  31. package/dist/components/toolbar/index.js +4 -0
  32. package/dist/components/{topbar-component/upload-img.js → toolbar/insert-image.js} +18 -15
  33. package/dist/components/toolbar/insert-table.js +155 -0
  34. package/dist/components/toolbar/table-group.js +82 -0
  35. package/dist/components/{toolbar.js → toolbar/toolbar.js} +102 -64
  36. package/dist/components/{topbar-component → toolbar/widgets}/button-group.js +0 -0
  37. package/dist/components/toolbar/widgets/button-item.js +144 -0
  38. package/dist/components/toolbar/widgets/drop-list.js +101 -0
  39. package/dist/components/user-help.js +16 -10
  40. package/dist/editor/controller/block-element-controller.js +6 -2
  41. package/dist/editor/controller/inline-element-controller.js +6 -2
  42. package/dist/editor/editor-builder.js +107 -0
  43. package/dist/editor/editor-component/formula.js +4 -2
  44. package/dist/editor/editor-component/image.js +10 -6
  45. package/dist/editor/editor-component/table.js +1 -1
  46. package/dist/editor/editor-plugin.js +3 -1
  47. package/dist/editor/editor.js +1 -32
  48. package/dist/editor/index.js +97 -0
  49. package/dist/editor/markdown-editor.js +323 -0
  50. package/dist/editor/plain-markdown-editor.js +5 -4
  51. package/dist/editor/simple-editor.js +44 -78
  52. package/dist/index.js +9 -0
  53. package/dist/utils/slate2markdown/serialize.js +12 -1
  54. package/dist/viewer/diff-viewer.js +1 -1
  55. package/dist/viewer/markdown-viewer.js +16 -15
  56. package/dist/viewer/slate-viewer.js +40 -28
  57. package/dist/viewer/viewer-formula.js +1 -1
  58. package/package.json +18 -17
  59. package/dist/components/comment-panel.js +0 -431
  60. package/dist/components/detail-list-view.js +0 -104
  61. package/dist/components/generate-share-link.js +0 -412
  62. package/dist/components/internal-link-dialog.js +0 -96
  63. package/dist/components/outline.js +0 -130
  64. package/dist/components/participants-list.js +0 -126
  65. package/dist/components/side-panel.js +0 -174
  66. package/dist/components/topbar-component/icon-button.js +0 -99
  67. package/dist/components/topbar-component/insert-file.js +0 -67
  68. package/dist/components/topbar-component/table-toolbar.js +0 -175
  69. package/dist/css/layout.css +0 -111
  70. package/dist/css/markdown-viewer-slate/file-tags-list.css +0 -76
  71. package/dist/css/react-mentions-default-style.js +0 -76
  72. package/dist/css/richeditor/comments-list.css +0 -184
  73. package/dist/css/richeditor/detail-list-view.css +0 -105
  74. package/dist/css/richeditor/document-info.css +0 -57
  75. package/dist/css/richeditor/participants-list.css +0 -22
  76. package/dist/css/richeditor/rich-editor-main.css +0 -32
  77. package/dist/css/richeditor/side-panel.css +0 -183
  78. package/dist/editor/rich-markdown-editor.js +0 -521
  79. package/dist/editor/seafile-editor.js +0 -325
  80. package/dist/editor-api.js +0 -256
  81. package/dist/index.css +0 -97
  82. package/dist/seafile-editor-chooser.js +0 -45
  83. package/dist/seafile-markdown-editor.js +0 -289
  84. package/dist/seafile-markdown-viewer.js +0 -78
  85. package/dist/seafile-simple-editor.js +0 -56
@@ -1,126 +0,0 @@
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 '../css/richeditor/participants-list.css';
8
-
9
- var ParticipantsList = /*#__PURE__*/function (_React$Component) {
10
- _inherits(ParticipantsList, _React$Component);
11
-
12
- var _super = _createSuper(ParticipantsList);
13
-
14
- function ParticipantsList(props) {
15
- var _this;
16
-
17
- _classCallCheck(this, ParticipantsList);
18
-
19
- _this = _super.call(this, props);
20
-
21
- _this.handleClick = function () {
22
- _this.props.openDialogs && _this.props.openDialogs('add-participant');
23
- };
24
-
25
- _this.tooltipToggle = function () {
26
- _this.setState({
27
- tooltipOpen: !_this.state.tooltipOpen
28
- });
29
- };
30
-
31
- _this.state = {
32
- tooltipOpen: false
33
- };
34
- return _this;
35
- }
36
-
37
- _createClass(ParticipantsList, [{
38
- key: "render",
39
- value: function render() {
40
- var participants = this.props.participants;
41
- return /*#__PURE__*/React.createElement("div", {
42
- className: "participants mb-2 position-relative"
43
- }, participants.map(function (item, index) {
44
- return /*#__PURE__*/React.createElement(Participant, {
45
- item: item,
46
- index: index,
47
- key: index
48
- });
49
- }), /*#__PURE__*/React.createElement("span", {
50
- className: "add-participants",
51
- onClick: this.handleClick,
52
- id: "add-participant-icon"
53
- }, /*#__PURE__*/React.createElement("i", {
54
- className: "iconfont icon-plus-circle"
55
- })), /*#__PURE__*/React.createElement(Tooltip, {
56
- toggle: this.tooltipToggle,
57
- delay: {
58
- show: 0,
59
- hide: 0
60
- },
61
- target: "add-participant-icon",
62
- placement: "bottom",
63
- isOpen: this.state.tooltipOpen
64
- }, this.props.t('Add_participants')));
65
- }
66
- }]);
67
-
68
- return ParticipantsList;
69
- }(React.Component);
70
-
71
- var Participant = /*#__PURE__*/function (_React$Component2) {
72
- _inherits(Participant, _React$Component2);
73
-
74
- var _super2 = _createSuper(Participant);
75
-
76
- function Participant(props) {
77
- var _this2;
78
-
79
- _classCallCheck(this, Participant);
80
-
81
- _this2 = _super2.call(this, props);
82
-
83
- _this2.toggleAvatarTooltip = function () {
84
- _this2.setState({
85
- showAvatarTooltip: !_this2.state.showAvatarTooltip
86
- });
87
- };
88
-
89
- _this2.state = {
90
- showAvatarTooltip: false
91
- };
92
- return _this2;
93
- }
94
-
95
- _createClass(Participant, [{
96
- key: "render",
97
- value: function render() {
98
- var _this$props = this.props,
99
- item = _this$props.item,
100
- index = _this$props.index;
101
- var target = 'participant-avatar-' + index;
102
- return /*#__PURE__*/React.createElement("span", {
103
- className: "participant-avatar"
104
- }, /*#__PURE__*/React.createElement("img", {
105
- src: item.avatar_url,
106
- className: "avatar",
107
- id: target,
108
- alt: "avatar",
109
- key: index
110
- }), /*#__PURE__*/React.createElement(Tooltip, {
111
- toggle: this.toggleAvatarTooltip,
112
- delay: {
113
- show: 0,
114
- hide: 0
115
- },
116
- target: target,
117
- placement: "bottom",
118
- isOpen: this.state.showAvatarTooltip
119
- }, item.name));
120
- }
121
- }]);
122
-
123
- return Participant;
124
- }(React.Component);
125
-
126
- export default ParticipantsList;
@@ -1,174 +0,0 @@
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
-
6
- /* eslint-disable jsx-a11y/anchor-is-valid */
7
- import React from 'react';
8
- import OutlineView from './outline';
9
- import CommentPanel from './comment-panel';
10
- import DetailListView from './detail-list-view';
11
-
12
- var SidePanel = /*#__PURE__*/function (_React$PureComponent) {
13
- _inherits(SidePanel, _React$PureComponent);
14
-
15
- var _super = _createSuper(SidePanel);
16
-
17
- function SidePanel() {
18
- var _this;
19
-
20
- _classCallCheck(this, SidePanel);
21
-
22
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
- args[_key] = arguments[_key];
24
- }
25
-
26
- _this = _super.call.apply(_super, [this].concat(args));
27
- _this.state = {
28
- navItem: 'outline'
29
- };
30
-
31
- _this.onOutlineClick = function (event) {
32
- event.preventDefault();
33
-
34
- _this.props.toggleCommentBtn(false);
35
-
36
- _this.setState({
37
- navItem: 'outline'
38
- });
39
- };
40
-
41
- _this.onMarkdownHintClick = function (event) {
42
- event.preventDefault();
43
-
44
- _this.props.toggleCommentBtn(false);
45
-
46
- _this.setState({
47
- navItem: 'markdownHint'
48
- });
49
- };
50
-
51
- _this.onDetailClick = function (event) {
52
- event.preventDefault();
53
-
54
- _this.props.toggleCommentBtn(false);
55
-
56
- _this.setState({
57
- navItem: 'detail'
58
- });
59
- };
60
-
61
- _this.onCommentsPanelClick = function (event) {
62
- event.preventDefault();
63
-
64
- _this.props.toggleCommentBtn(true);
65
-
66
- _this.setState({
67
- navItem: 'commentsPanel'
68
- });
69
- };
70
-
71
- _this.openMarkdownHint = function () {
72
- _this.setState({
73
- navItem: 'markdownHint'
74
- });
75
- };
76
-
77
- return _this;
78
- }
79
-
80
- _createClass(SidePanel, [{
81
- key: "componentDidMount",
82
- value: function componentDidMount() {
83
- window.openMarkdownHint = this.openMarkdownHint;
84
- }
85
- }, {
86
- key: "componentWillReceiveProps",
87
- value: function componentWillReceiveProps(nextProps) {
88
- if (nextProps.issues !== this.props.issues) {
89
- if (nextProps.issues.issue_list.length > 0) {
90
- this.setState({
91
- navItem: 'markdownHint'
92
- });
93
- }
94
- }
95
- }
96
- }, {
97
- key: "componentWillUnmount",
98
- value: function componentWillUnmount() {
99
- window.openMarkdownHint = null;
100
- }
101
- }, {
102
- key: "render",
103
- value: function render() {
104
- var outlineActive = ''; // var markdownHint = '';
105
-
106
- var commentsPanel = '';
107
- var detailList = '';
108
-
109
- if (this.state.navItem === 'outline') {
110
- outlineActive = 'active';
111
- } else if (this.state.navItem === 'commentsPanel') {
112
- commentsPanel = 'active';
113
- } else if (this.state.navItem === 'detail') {
114
- detailList = 'active';
115
- } else {// markdownHint = 'active';
116
- }
117
-
118
- return /*#__PURE__*/React.createElement("div", {
119
- className: "side-panel d-flex flex-column"
120
- }, /*#__PURE__*/React.createElement("ul", {
121
- className: "flex-shrink-0 nav justify-content-around bg-white"
122
- }, /*#__PURE__*/React.createElement("li", {
123
- className: "nav-item"
124
- }, /*#__PURE__*/React.createElement("a", {
125
- className: 'nav-link ' + outlineActive,
126
- href: "",
127
- onClick: this.onOutlineClick
128
- }, /*#__PURE__*/React.createElement("i", {
129
- className: "iconfont icon-list-ul"
130
- }))), /*#__PURE__*/React.createElement("li", {
131
- className: "nav-item"
132
- }, /*#__PURE__*/React.createElement("a", {
133
- className: 'nav-link ' + detailList,
134
- href: "",
135
- onClick: this.onDetailClick
136
- }, /*#__PURE__*/React.createElement("i", {
137
- className: 'iconfont icon-info-circle'
138
- }))), /*#__PURE__*/React.createElement("li", {
139
- className: "nav-item"
140
- }, /*#__PURE__*/React.createElement("a", {
141
- className: 'nav-link ' + commentsPanel,
142
- href: "",
143
- onClick: this.onCommentsPanelClick
144
- }, /*#__PURE__*/React.createElement("i", {
145
- className: 'iconfont icon-comment'
146
- })))), /*#__PURE__*/React.createElement("div", {
147
- className: "side-panel-content flex-fill"
148
- }, this.state.navItem === 'outline' && /*#__PURE__*/React.createElement(OutlineView, {
149
- editor: this.props.editor,
150
- document: this.props.document,
151
- t: this.props.t
152
- }), this.state.navItem === 'commentsPanel' && /*#__PURE__*/React.createElement(CommentPanel, {
153
- editorApi: this.props.editorApi,
154
- t: this.props.t,
155
- scrollToQuote: this.props.scrollToQuote,
156
- relistComment: this.props.relistComment,
157
- openDialogs: this.props.openDialogs,
158
- participants: this.props.participants,
159
- onParticipantsChange: this.props.onParticipantsChange
160
- }), this.state.navItem === 'detail' && /*#__PURE__*/React.createElement(DetailListView, {
161
- t: this.props.t,
162
- fileTagList: this.props.fileTagList,
163
- editorApi: this.props.editorApi,
164
- openDialogs: this.props.openDialogs,
165
- fileInfo: this.props.fileInfo,
166
- participants: this.props.participants
167
- })));
168
- }
169
- }]);
170
-
171
- return SidePanel;
172
- }(React.PureComponent);
173
-
174
- export default SidePanel;
@@ -1,99 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- import React from 'react';
7
- import { Tooltip } from 'reactstrap';
8
- import { withTranslation } from 'react-i18next';
9
-
10
- var IconButton = /*#__PURE__*/function (_React$Component) {
11
- _inherits(IconButton, _React$Component);
12
-
13
- var _super = _createSuper(IconButton);
14
-
15
- function IconButton(props) {
16
- var _this;
17
-
18
- _classCallCheck(this, IconButton);
19
-
20
- _this = _super.call(this, props);
21
-
22
- _this.toggle = function () {
23
- if (_this.props.disabled || _this.state.isFreezed && !_this.state.tooltipOpen) return;
24
-
25
- _this.setState({
26
- tooltipOpen: !_this.state.tooltipOpen,
27
- isFreezed: true
28
- });
29
-
30
- var that = _assertThisInitialized(_this);
31
-
32
- setTimeout(function () {
33
- that.setState({
34
- isFreezed: false
35
- });
36
- }, 100);
37
- };
38
-
39
- _this.getClassName = function () {
40
- var className = _this.props.isRichEditor ? 'rich-icon-btn ' + (_this.props.disabled ? 'rich-icon-btn-disabled' : 'rich-icon-btn-hover') : 'btn btn-icon btn-secondary btn-active';
41
- className = className + ' ' + (_this.props.className || '');
42
- return className;
43
- };
44
-
45
- _this.state = {
46
- tooltipOpen: false,
47
- isFreezed: false
48
- };
49
- return _this;
50
- }
51
-
52
- _createClass(IconButton, [{
53
- key: "shouldComponentUpdate",
54
- value: function shouldComponentUpdate(nextProps, nextState) {
55
- if (this.props.disabled !== nextProps.disabled) {
56
- this.setState({
57
- tooltipOpen: false
58
- });
59
- return true;
60
- } // only render iconButton when the button is active or show show tooltip
61
-
62
-
63
- if (nextState.tooltipOpen === this.state.tooltipOpen && nextProps.isActive === this.props.isActive) {
64
- return false;
65
- }
66
-
67
- return true;
68
- }
69
- }, {
70
- key: "render",
71
- value: function render() {
72
- var className = this.getClassName();
73
- return /*#__PURE__*/React.createElement("button", {
74
- id: this.props.id,
75
- type: 'button',
76
- onClick: this.props.disabled ? null : this.props.onClick,
77
- onMouseDown: this.props.disabled ? null : this.props.onMouseDown,
78
- className: className,
79
- "data-active": this.props.isActive || false,
80
- disabled: this.props.disabled
81
- }, /*#__PURE__*/React.createElement("i", {
82
- className: this.props.icon
83
- }), /*#__PURE__*/React.createElement(Tooltip, {
84
- toggle: this.toggle,
85
- delay: {
86
- show: 0,
87
- hide: 0
88
- },
89
- target: this.props.id,
90
- placement: "bottom",
91
- isOpen: this.state.tooltipOpen
92
- }, this.props.text));
93
- }
94
- }]);
95
-
96
- return IconButton;
97
- }(React.Component);
98
-
99
- export default withTranslation('seafile-editor')(IconButton);
@@ -1,67 +0,0 @@
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 InsertFile = /*#__PURE__*/function (_React$Component) {
10
- _inherits(InsertFile, _React$Component);
11
-
12
- var _super = _createSuper(InsertFile);
13
-
14
- function InsertFile(props) {
15
- var _this;
16
-
17
- _classCallCheck(this, InsertFile);
18
-
19
- _this = _super.call(this, props);
20
-
21
- _this.toggle = function () {
22
- if (_this.props.disabled) {
23
- _this.setState({
24
- tooltipOpen: false
25
- });
26
-
27
- return;
28
- } else {
29
- _this.setState({
30
- tooltipOpen: !_this.state.tooltipOpen
31
- });
32
- }
33
- };
34
-
35
- _this.state = {
36
- tooltipOpen: false
37
- };
38
- return _this;
39
- }
40
-
41
- _createClass(InsertFile, [{
42
- key: "render",
43
- value: function render() {
44
- var className = this.props.disabled ? 'insert-file insert-file-disabled rich-icon-btn rich-icon-btn-disabled' : 'insert-file rich-icon-btn';
45
- return /*#__PURE__*/React.createElement("span", {
46
- className: className,
47
- id: "insertFileButton",
48
- onMouseDown: this.props.insertRepoFile
49
- }, /*#__PURE__*/React.createElement("i", {
50
- className: "iconfont icon-file"
51
- }), /*#__PURE__*/React.createElement(Tooltip, {
52
- toggle: this.toggle,
53
- delay: {
54
- show: 0,
55
- hide: 0
56
- },
57
- target: "insertFileButton",
58
- placement: "bottom",
59
- isOpen: this.state.tooltipOpen
60
- }, this.props.t('insert_file')));
61
- }
62
- }]);
63
-
64
- return InsertFile;
65
- }(React.Component);
66
-
67
- export default withTranslation('seafile-editor')(InsertFile);
@@ -1,175 +0,0 @@
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
- import IconButton from './icon-button';
8
- import ButtonGroup from './button-group';
9
- import { withTranslation } from 'react-i18next';
10
-
11
- var TableToolBar = /*#__PURE__*/function (_React$PureComponent) {
12
- _inherits(TableToolBar, _React$PureComponent);
13
-
14
- var _super = _createSuper(TableToolBar);
15
-
16
- function TableToolBar() {
17
- _classCallCheck(this, TableToolBar);
18
-
19
- return _super.apply(this, arguments);
20
- }
21
-
22
- _createClass(TableToolBar, [{
23
- key: "render",
24
- value: function render() {
25
- var _this = this;
26
-
27
- return /*#__PURE__*/React.createElement(ButtonGroup, {
28
- className: 'editor-btn-group'
29
- }, /*#__PURE__*/React.createElement(DropList, {
30
- icon: 'iconfont icon-left-alignment',
31
- items: [{
32
- handle: function handle(e) {
33
- _this.props.onSetAlign(e, 'left');
34
- },
35
- icon: 'iconfont icon-left-alignment',
36
- text: this.props.t('left')
37
- }, {
38
- handle: function handle(e) {
39
- _this.props.onSetAlign(e, 'center');
40
- },
41
- icon: 'iconfont icon-center-horizontally',
42
- text: this.props.t('center')
43
- }, {
44
- handle: function handle(e) {
45
- _this.props.onSetAlign(e, 'right');
46
- },
47
- icon: 'icon icon-align-right',
48
- text: this.props.t('right')
49
- }]
50
- }), /*#__PURE__*/React.createElement(DropList, {
51
- icon: 'iconfont icon-column',
52
- items: [{
53
- handle: this.props.onInsertColumn,
54
- text: this.props.t('Insert_Column')
55
- }, {
56
- handle: this.props.onRemoveColumn,
57
- text: this.props.t('Remove_Column')
58
- }]
59
- }), /*#__PURE__*/React.createElement(DropList, {
60
- icon: 'iconfont icon-row',
61
- items: [{
62
- handle: this.props.onInsertRow,
63
- text: this.props.t('Insert_Row')
64
- }, {
65
- handle: this.props.onRemoveRow,
66
- text: this.props.t('Remove_Row')
67
- }]
68
- }), /*#__PURE__*/React.createElement(IconButton, {
69
- disabled: false,
70
- isRichEditor: true,
71
- text: this.props.t('remove_table'),
72
- id: 'removeTable',
73
- icon: 'iconfont icon-delete-table',
74
- onMouseDown: this.props.onRemoveTable
75
- }));
76
- }
77
- }]);
78
-
79
- return TableToolBar;
80
- }(React.PureComponent);
81
-
82
- var DropList = /*#__PURE__*/function (_React$PureComponent2) {
83
- _inherits(DropList, _React$PureComponent2);
84
-
85
- var _super2 = _createSuper(DropList);
86
-
87
- function DropList(props) {
88
- var _this2;
89
-
90
- _classCallCheck(this, DropList);
91
-
92
- _this2 = _super2.call(this, props);
93
-
94
- _this2.handleClick = function (event) {
95
- if (_this2.props.disabled) return;
96
-
97
- var container = _this2.getContainer();
98
-
99
- if (container.contains(event.target)) {
100
- _this2.toggle();
101
- } else {
102
- if (_this2.state.dropdownOpen) {
103
- _this2.setState({
104
- dropdownOpen: !_this2.state.dropdownOpen
105
- });
106
- }
107
- }
108
- };
109
-
110
- _this2.toggle = function () {
111
- _this2.setState({
112
- dropdownOpen: !_this2.state.dropdownOpen
113
- });
114
- };
115
-
116
- _this2.state = {
117
- dropdownOpen: false
118
- };
119
- return _this2;
120
- }
121
-
122
- _createClass(DropList, [{
123
- key: "getContainer",
124
- value: function getContainer() {
125
- return ReactDOM.findDOMNode(this);
126
- }
127
- }, {
128
- key: "componentDidMount",
129
- value: function componentDidMount() {
130
- document.addEventListener('click', this.handleClick);
131
- }
132
- }, {
133
- key: "componentWillUnmount",
134
- value: function componentWillUnmount() {
135
- document.removeEventListener('click', this.handleClick);
136
- }
137
- }, {
138
- key: "render",
139
- value: function render() {
140
- var items = [];
141
- this.props.items.forEach(function (item, index) {
142
- items.push( /*#__PURE__*/React.createElement("button", {
143
- key: 'dropdown-item' + index,
144
- onMouseDown: item.handle,
145
- className: 'dropdown-item'
146
- }, item.icon ? /*#__PURE__*/React.createElement("i", {
147
- className: item.icon,
148
- style: {
149
- marginRight: '6px'
150
- }
151
- }) : null, item.text));
152
- });
153
- return /*#__PURE__*/React.createElement("div", {
154
- className: 'custom-dropdown-list'
155
- }, /*#__PURE__*/React.createElement("div", {
156
- id: 'list_toggle',
157
- className: 'dropdown-list-toggle'
158
- }, /*#__PURE__*/React.createElement("i", {
159
- className: this.props.icon,
160
- style: {
161
- marginRight: '3px'
162
- }
163
- }), /*#__PURE__*/React.createElement("i", {
164
- className: this.state.dropdownOpen ? 'iconfont icon-caret-up' : 'iconfont icon-drop-down'
165
- })), this.state.dropdownOpen && /*#__PURE__*/React.createElement("div", {
166
- role: 'menu',
167
- className: 'custom-dropdown-menu dropdown-menu'
168
- }, items));
169
- }
170
- }]);
171
-
172
- return DropList;
173
- }(React.PureComponent);
174
-
175
- export default withTranslation('seafile-editor')(TableToolBar);