@seafile/sdoc-editor 0.1.0 → 0.1.1

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 (144) hide show
  1. package/dist/{new-editors/editor.js → editor.js} +23 -17
  2. package/dist/index.js +2 -36
  3. package/dist/slate-extension/plugins/index.js +3 -2
  4. package/dist/slate-extension/plugins/socket/index.js +6 -0
  5. package/dist/slate-extension/plugins/socket/plugin.js +17 -0
  6. package/dist/slate-extension/socket/socket-client.js +84 -0
  7. package/dist/slate-extension/socket/socket-manager.js +61 -0
  8. package/dist/slate-extension/toolbar/index.js +1 -1
  9. package/package.json +3 -23
  10. package/dist/assets/css/comment-dialog.css +0 -50
  11. package/dist/assets/css/diff-viewer.css +0 -105
  12. package/dist/assets/css/formula.css +0 -19
  13. package/dist/assets/css/history-viewer.css +0 -104
  14. package/dist/assets/css/image.css +0 -134
  15. package/dist/assets/css/issue-card.css +0 -43
  16. package/dist/assets/css/keyboard-shortcuts.css +0 -58
  17. package/dist/assets/css/link.css +0 -7
  18. package/dist/assets/css/markdown-editor.css +0 -12
  19. package/dist/assets/css/markdown-viewer.css +0 -69
  20. package/dist/assets/css/navbar-imgbutton.css +0 -83
  21. package/dist/assets/css/outline.css +0 -29
  22. package/dist/assets/css/table.css +0 -57
  23. package/dist/assets/css/textlink-hovermenu.css +0 -47
  24. package/dist/assets/css/topbar.css +0 -350
  25. package/dist/assets/css/tree-view.css +0 -67
  26. package/dist/assets/css/user-help.css +0 -84
  27. package/dist/assets/editor/plain-editor.css +0 -30
  28. package/dist/assets/editor/seatable-editor.css +0 -77
  29. package/dist/assets/editor/simple-editor.css +0 -77
  30. package/dist/components/click-outside.js +0 -46
  31. package/dist/components/context-menu.js +0 -97
  32. package/dist/components/dialogs/add-formula-dialog.js +0 -116
  33. package/dist/components/dialogs/add-image-dialog.js +0 -69
  34. package/dist/components/dialogs/add-link-dialog.js +0 -133
  35. package/dist/components/dialogs/comment-dialog.js +0 -97
  36. package/dist/components/dialogs/shortcut-dialog.js +0 -131
  37. package/dist/components/error-boundary.js +0 -28
  38. package/dist/components/load-script/index.js +0 -69
  39. package/dist/components/loading.js +0 -25
  40. package/dist/components/markdown-lint.js +0 -72
  41. package/dist/components/menu/index.js +0 -4
  42. package/dist/components/menu/item.js +0 -49
  43. package/dist/components/menu/menu.js +0 -38
  44. package/dist/components/menu/style.css +0 -42
  45. package/dist/components/modal-portal.js +0 -38
  46. package/dist/components/outline/index.js +0 -92
  47. package/dist/components/outline/outline-item.js +0 -58
  48. package/dist/components/select/_option.js +0 -44
  49. package/dist/components/select/field-setting.js +0 -106
  50. package/dist/components/select/index.js +0 -149
  51. package/dist/components/select/style.css +0 -144
  52. package/dist/components/svg-icons/check-mark-icon.js +0 -14
  53. package/dist/components/svg-icons/column-icon.js +0 -17
  54. package/dist/components/svg-icons/text-icon.js +0 -34
  55. package/dist/components/text-link-hover-menu/index.js +0 -123
  56. package/dist/components/toast/alert.js +0 -138
  57. package/dist/components/toast/index.js +0 -3
  58. package/dist/components/toast/toast.js +0 -159
  59. package/dist/components/toast/toastManager.js +0 -139
  60. package/dist/components/toast/toaster.js +0 -65
  61. package/dist/components/toolbar/header-list.js +0 -114
  62. package/dist/components/toolbar/help-group.js +0 -33
  63. package/dist/components/toolbar/index.js +0 -4
  64. package/dist/components/toolbar/insert-image.js +0 -106
  65. package/dist/components/toolbar/insert-table.js +0 -136
  66. package/dist/components/toolbar/table-group.js +0 -74
  67. package/dist/components/toolbar/toolbar.js +0 -317
  68. package/dist/components/toolbar/widgets/button-group.js +0 -24
  69. package/dist/components/toolbar/widgets/button-item.js +0 -129
  70. package/dist/components/toolbar/widgets/drop-list.js +0 -88
  71. package/dist/components/user-help/index.js +0 -179
  72. package/dist/config-0.js +0 -15
  73. package/dist/config.js +0 -16
  74. package/dist/constants/cell-types.js +0 -29
  75. package/dist/constants/column.js +0 -4
  76. package/dist/containers/code-highlight-package.js +0 -14
  77. package/dist/containers/controller/block-element-controller.js +0 -375
  78. package/dist/containers/controller/index.js +0 -5
  79. package/dist/containers/controller/inline-element-controller.js +0 -134
  80. package/dist/containers/controller/normalize-controller.js +0 -95
  81. package/dist/containers/controller/shortcut-controller.js +0 -385
  82. package/dist/containers/controller/void-element-controller.js +0 -9
  83. package/dist/containers/custom/custom.js +0 -18
  84. package/dist/containers/custom/get-event-transfer.js +0 -33
  85. package/dist/containers/custom/getNodesByTypeAtRange.js +0 -57
  86. package/dist/containers/custom/insertNodes.js +0 -120
  87. package/dist/containers/custom/is-empty-paragraph.js +0 -9
  88. package/dist/containers/custom/set-event-transfer.js +0 -30
  89. package/dist/containers/custom/split-nodes-at-point.js +0 -136
  90. package/dist/containers/custom/unwrap-node-by-type-at-range.js +0 -70
  91. package/dist/containers/editor-context.js +0 -85
  92. package/dist/containers/editor-utils/block-element-utils/blockquote-utils.js +0 -80
  93. package/dist/containers/editor-utils/block-element-utils/code-utils.js +0 -145
  94. package/dist/containers/editor-utils/block-element-utils/formula-utils.js +0 -51
  95. package/dist/containers/editor-utils/block-element-utils/index.js +0 -31
  96. package/dist/containers/editor-utils/block-element-utils/list-utils.js +0 -395
  97. package/dist/containers/editor-utils/block-element-utils/table-utils.js +0 -412
  98. package/dist/containers/editor-utils/clear-format-utils.js +0 -84
  99. package/dist/containers/editor-utils/common-editor-utils.js +0 -492
  100. package/dist/containers/editor-utils/inline-element-utils/index.js +0 -95
  101. package/dist/containers/editor-utils/mark-utils.js +0 -20
  102. package/dist/containers/editor-utils/range-utils.js +0 -7
  103. package/dist/containers/editor-utils/selection-utils.js +0 -30
  104. package/dist/containers/editor-utils/text-utils.js +0 -117
  105. package/dist/containers/editor-widgets/check-list-item.js +0 -53
  106. package/dist/containers/editor-widgets/code-block.js +0 -128
  107. package/dist/containers/editor-widgets/column.js +0 -100
  108. package/dist/containers/editor-widgets/formula.js +0 -67
  109. package/dist/containers/editor-widgets/image.js +0 -237
  110. package/dist/containers/editor-widgets/link.js +0 -9
  111. package/dist/containers/editor-widgets/table.js +0 -144
  112. package/dist/containers/element-model/blockquote.js +0 -13
  113. package/dist/containers/element-model/column.js +0 -19
  114. package/dist/containers/element-model/image.js +0 -16
  115. package/dist/containers/element-model/link.js +0 -16
  116. package/dist/containers/element-model/table.js +0 -57
  117. package/dist/containers/element-model/text.js +0 -10
  118. package/dist/containers/render-utils/common-utils.js +0 -80
  119. package/dist/containers/render-utils/editor-utils.js +0 -133
  120. package/dist/containers/render-utils/viewer-utils.js +0 -198
  121. package/dist/containers/viewer-widgets/viewer-formula/index.js +0 -54
  122. package/dist/containers/viewer-widgets/viewer-image/index.js +0 -70
  123. package/dist/containers/viewer-widgets/viewer-image/viewer-image.css +0 -3
  124. package/dist/editors/index.js +0 -78
  125. package/dist/editors/markdown-editor.js +0 -280
  126. package/dist/editors/plain-markdown-editor.js +0 -285
  127. package/dist/editors/seatable-editor.js +0 -210
  128. package/dist/editors/simple-editor.js +0 -200
  129. package/dist/utils/deserialize-html.js +0 -260
  130. package/dist/utils/diff/compare-strings.js +0 -35
  131. package/dist/utils/diff/diff.js +0 -769
  132. package/dist/utils/diff/index.js +0 -2
  133. package/dist/utils/seafile-markdown2html.js +0 -52
  134. package/dist/utils/slate2markdown/deserialize.js +0 -588
  135. package/dist/utils/slate2markdown/index.js +0 -3
  136. package/dist/utils/slate2markdown/serialize.js +0 -366
  137. package/dist/utils/utils.js +0 -69
  138. package/dist/viewer/diff-viewer.js +0 -85
  139. package/dist/viewer/index.js +0 -4
  140. package/dist/viewer/markdown-viewer.js +0 -121
  141. package/dist/viewer/seatable-viewer.js +0 -63
  142. package/dist/viewer/slate-viewer.js +0 -71
  143. /package/dist/assets/css/{new-editor-toolbar.css → sdoc-editor-toolbar.css} +0 -0
  144. /package/dist/assets/css/{new-editor.css → sdoc-editor.css} +0 -0
@@ -1,136 +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, { Component } from 'react';
6
- import ClickOutside from '../click-outside';
7
- import ButtonItem from './widgets/button-item';
8
- var InsertTable = /*#__PURE__*/function (_Component) {
9
- _inherits(InsertTable, _Component);
10
- var _super = _createSuper(InsertTable);
11
- function InsertTable(props) {
12
- var _this;
13
- _classCallCheck(this, InsertTable);
14
- _this = _super.call(this, props);
15
- _this.toggleCard = function (event) {
16
- if (event) {
17
- event.stopPropagation();
18
- event.nativeEvent.stopImmediatePropagation();
19
- }
20
- _this.setState({
21
- showCard: !_this.state.showCard,
22
- columnCount: -1,
23
- rowCount: -1
24
- });
25
- };
26
- _this.createTableCells = function () {
27
- var rows = [];
28
- var _this$state = _this.state,
29
- columnCount = _this$state.columnCount,
30
- rowCount = _this$state.rowCount,
31
- currentMaxColumnCount = _this$state.currentMaxColumnCount,
32
- currentMaxRowCount = _this$state.currentMaxRowCount;
33
- var _loop = function _loop(rowIndex) {
34
- var cells = [];
35
- var _loop2 = function _loop2(columnIndex) {
36
- var isActive = columnIndex <= columnCount - 1 && rowIndex <= rowCount - 1;
37
- var vDom = /*#__PURE__*/React.createElement("div", {
38
- onMouseEnter: function onMouseEnter() {
39
- return _this.onTableCellMouseEnter(rowIndex, columnIndex);
40
- },
41
- key: "table-row-".concat(rowIndex, "-").concat(columnIndex),
42
- className: "sf-editor-table-card-cell ".concat(isActive ? 'sf-editor-table-card-active-cell' : '')
43
- });
44
- cells.push(vDom);
45
- };
46
- for (var columnIndex = 0; columnIndex < currentMaxColumnCount; columnIndex++) {
47
- _loop2(columnIndex);
48
- }
49
- var row = /*#__PURE__*/React.createElement("div", {
50
- key: "table-row-".concat(rowIndex),
51
- className: "sf-editor-table-card-row"
52
- }, cells);
53
- rows.push(row);
54
- };
55
- for (var rowIndex = 0; rowIndex < currentMaxRowCount; rowIndex++) {
56
- _loop(rowIndex);
57
- }
58
- return /*#__PURE__*/React.createElement("div", {
59
- onClick: function onClick(event) {
60
- return _this.onAddTable(event, rowCount, columnCount);
61
- },
62
- className: "sf-editor-table-card"
63
- }, rows);
64
- };
65
- _this.onAddTable = function (event, rowCount, columnCount) {
66
- _this.props.onAddTable(event, rowCount, columnCount);
67
- _this.toggleCard();
68
- };
69
- _this.onTableCellMouseEnter = function (rowIndex, columnIndex) {
70
- var columnCount = columnIndex + 1,
71
- rowCount = rowIndex + 1;
72
- var currentMaxRowCount = rowCount + 1,
73
- currentMaxColumnCount = columnCount + 1;
74
- if (currentMaxColumnCount > 10) {
75
- currentMaxColumnCount = 10;
76
- } else if (currentMaxColumnCount < 4) {
77
- currentMaxColumnCount = 4;
78
- }
79
- if (currentMaxRowCount > 10) {
80
- currentMaxRowCount = 10;
81
- } else if (currentMaxRowCount < 4) {
82
- currentMaxRowCount = 4;
83
- }
84
- _this.setState({
85
- columnCount: columnCount,
86
- rowCount: rowCount,
87
- currentMaxColumnCount: currentMaxColumnCount,
88
- currentMaxRowCount: currentMaxRowCount
89
- });
90
- };
91
- _this.state = {
92
- showCard: false,
93
- currentMaxColumnCount: 4,
94
- currentMaxRowCount: 4,
95
- columnCount: -1,
96
- rowCount: -1
97
- };
98
- return _this;
99
- }
100
- _createClass(InsertTable, [{
101
- key: "createTableScaleCard",
102
- value: function createTableScaleCard(props) {
103
- var _this$state2 = this.state,
104
- columnCount = _this$state2.columnCount,
105
- rowCount = _this$state2.rowCount;
106
- return /*#__PURE__*/React.createElement("div", {
107
- className: "sf-editor-table-count-card"
108
- }, /*#__PURE__*/React.createElement("div", {
109
- className: "sf-editor-table-cells-header"
110
- }, "".concat(columnCount < 0 ? 0 : columnCount, " x ").concat(rowCount < 0 ? 0 : rowCount)), this.createTableCells());
111
- }
112
- }, {
113
- key: "render",
114
- value: function render() {
115
- var _this$props = this.props,
116
- disabled = _this$props.disabled,
117
- isRichEditor = _this$props.isRichEditor,
118
- text = _this$props.text;
119
- var showCard = this.state.showCard;
120
- return /*#__PURE__*/React.createElement("div", {
121
- className: "sf-editor-table-btn-wrapper"
122
- }, /*#__PURE__*/React.createElement(ButtonItem, {
123
- disabled: disabled,
124
- isRichEditor: isRichEditor,
125
- text: text,
126
- id: 'tableButton',
127
- icon: 'iconfont icon-table',
128
- onMouseDown: this.toggleCard
129
- }), showCard && /*#__PURE__*/React.createElement(ClickOutside, {
130
- clickOutside: this.toggleCard
131
- }, this.createTableScaleCard()));
132
- }
133
- }]);
134
- return InsertTable;
135
- }(Component);
136
- export default InsertTable;
@@ -1,74 +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 { withTranslation } from 'react-i18next';
7
- import ButtonGroup from './widgets/button-group';
8
- import ButtonItem from './widgets/button-item';
9
- import DropList from './widgets/drop-list';
10
- var InsertTable = /*#__PURE__*/function (_React$PureComponent) {
11
- _inherits(InsertTable, _React$PureComponent);
12
- var _super = _createSuper(InsertTable);
13
- function InsertTable() {
14
- _classCallCheck(this, InsertTable);
15
- return _super.apply(this, arguments);
16
- }
17
- _createClass(InsertTable, [{
18
- key: "render",
19
- value: function render() {
20
- var _this = this;
21
- return /*#__PURE__*/React.createElement(ButtonGroup, {
22
- className: 'editor-btn-group'
23
- }, /*#__PURE__*/React.createElement(DropList, {
24
- icon: 'iconfont icon-left-alignment',
25
- items: [{
26
- handle: function handle(e) {
27
- _this.props.onSetAlign(e, 'left');
28
- },
29
- icon: 'iconfont icon-left-alignment',
30
- text: this.props.t('left')
31
- }, {
32
- handle: function handle(e) {
33
- _this.props.onSetAlign(e, 'center');
34
- },
35
- icon: 'iconfont icon-center-horizontally',
36
- text: this.props.t('center')
37
- }, {
38
- handle: function handle(e) {
39
- _this.props.onSetAlign(e, 'right');
40
- },
41
- icon: 'icon icon-align-right',
42
- text: this.props.t('right')
43
- }]
44
- }), /*#__PURE__*/React.createElement(DropList, {
45
- icon: 'iconfont icon-column',
46
- items: [{
47
- handle: this.props.onInsertColumn,
48
- text: this.props.t('Insert_Column')
49
- }, {
50
- handle: this.props.onRemoveColumn,
51
- text: this.props.t('Remove_Column')
52
- }]
53
- }), /*#__PURE__*/React.createElement(DropList, {
54
- icon: 'iconfont icon-row',
55
- items: [{
56
- handle: this.props.onInsertRow,
57
- text: this.props.t('Insert_Row')
58
- }, {
59
- handle: this.props.onRemoveRow,
60
- text: this.props.t('Remove_Row')
61
- }]
62
- }), /*#__PURE__*/React.createElement(ButtonItem, {
63
- disabled: false,
64
- isRichEditor: true,
65
- text: this.props.t('remove_table'),
66
- id: 'removeTable',
67
- icon: 'iconfont icon-delete-table',
68
- onMouseDown: this.props.onRemoveTable
69
- }));
70
- }
71
- }]);
72
- return InsertTable;
73
- }(React.PureComponent);
74
- export default withTranslation('seafile-editor')(InsertTable);
@@ -1,317 +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, { Fragment } from 'react';
7
- import { withTranslation } from 'react-i18next';
8
- import EditorContext from '../../containers/editor-context';
9
- import ButtonItem from './widgets/button-item';
10
- import ButtonGroup from './widgets/button-group';
11
- import HeaderList from './header-list';
12
- import InsertTable from './insert-table';
13
- import InsertImage from './insert-image';
14
- import TableGroup from './table-group';
15
- import AddLinkDialog from '../dialogs/add-link-dialog';
16
- import AddImageDialog from '../dialogs/add-image-dialog';
17
- import AddFormulaDialog from '../dialogs/add-formula-dialog';
18
- import ColumnIcon from '../svg-icons/column-icon';
19
- import '../../assets/css/topbar.css';
20
- var Toolbar = /*#__PURE__*/function (_React$Component) {
21
- _inherits(Toolbar, _React$Component);
22
- var _super = _createSuper(Toolbar);
23
- function Toolbar(props) {
24
- var _this;
25
- _classCallCheck(this, Toolbar);
26
- _this = _super.call(this, props);
27
- _this.onClickHeader = function (event, type) {
28
- event.preventDefault();
29
- _this.editorUtils.clickHeader(type);
30
- };
31
- _this.onClickMark = function (type) {
32
- return function (event) {
33
- event.preventDefault();
34
- _this.editorUtils.clickMark(type);
35
- };
36
- };
37
- _this.onClickBlock = function (type) {
38
- return function (event) {
39
- event.preventDefault();
40
- _this.editorUtils.clickBlock(type);
41
- };
42
- };
43
- _this.onClearFormat = function (event) {
44
- event.preventDefault();
45
- _this.editorUtils.clearFormat();
46
- };
47
- _this.onClickCheckItem = function (event) {
48
- event.preventDefault();
49
- _this.editorUtils.clickCheckItem();
50
- };
51
- _this.onAddTable = function (event, rowCount, columnCount) {
52
- event.preventDefault();
53
- _this.editorUtils.addTable(rowCount, columnCount);
54
- };
55
- _this.onInsertImage = function (data) {
56
- _this.editorUtils.insertImage(data);
57
- };
58
- _this.onAddCustomColumn = function (event) {
59
- event.preventDefault();
60
- event.nativeEvent.stopImmediatePropagation();
61
- _this.editorUtils.addCustomColumn();
62
- };
63
- _this.onRemoveTable = function (event) {
64
- event.preventDefault();
65
- _this.editorUtils.removeTable();
66
- };
67
- _this.onInsertColumn = function (event) {
68
- event.preventDefault();
69
- _this.editorUtils.insertColumn();
70
- };
71
- _this.onRemoveColumn = function (event) {
72
- event.preventDefault();
73
- _this.editorUtils.removeColumn();
74
- };
75
- _this.onInsertRow = function (event) {
76
- event.preventDefault();
77
- _this.editorUtils.insertRow();
78
- };
79
- _this.onRemoveRow = function (event) {
80
- event.preventDefault();
81
- _this.editorUtils.removeRow();
82
- };
83
- _this.onSetAlign = function (event, align) {
84
- event.preventDefault();
85
- _this.editorUtils.setAlign(align);
86
- };
87
- _this.onToggleLink = function (event) {
88
- event.preventDefault();
89
- var isLinkActive = _this.editorUtils.isLinkActive();
90
- if (!isLinkActive) {
91
- _this.setState({
92
- isShowLinkDialog: !_this.state.isShowLinkDialog
93
- });
94
- return;
95
- }
96
- _this.editorUtils.unwrapLink();
97
- };
98
- _this.onToggleLinkDialog = function () {
99
- _this.setState({
100
- isShowLinkDialog: !_this.state.isShowLinkDialog
101
- });
102
- };
103
- _this.onToggleFormulaDialog = function () {
104
- _this.setState({
105
- isShowFormulaDialog: !_this.state.isShowFormulaDialog
106
- });
107
- };
108
- _this.onToggleImageDialog = function () {
109
- _this.setState({
110
- isShowImageDialog: !_this.state.isShowImageDialog
111
- });
112
- };
113
- _this.state = {
114
- isShowLinkDialog: false,
115
- isShowImageDialog: false,
116
- isShowFormulaDialog: false
117
- };
118
- _this.editorUtils = EditorContext.getEditorUtils();
119
- window.abcdef_editorToolbar = _assertThisInitialized(_this);
120
- return _this;
121
- }
122
- _createClass(Toolbar, [{
123
- key: "render",
124
- value: function render() {
125
- var _this$props = this.props,
126
- hasSidePanel = _this$props.hasSidePanel,
127
- isShowSidePanel = _this$props.isShowSidePanel,
128
- canInsertColumn = _this$props.canInsertColumn,
129
- t = _this$props.t;
130
- var toolbarStatus = this.editorUtils.getToolbarStatus();
131
- var isTableActive = toolbarStatus.isTableActive,
132
- isCodeActive = toolbarStatus.isCodeActive,
133
- isBoldActive = toolbarStatus.isBoldActive,
134
- isItalicActive = toolbarStatus.isItalicActive,
135
- isInlineCodeActive = toolbarStatus.isInlineCodeActive,
136
- isLinkActive = toolbarStatus.isLinkActive,
137
- isBlockquoteActive = toolbarStatus.isBlockquoteActive,
138
- isOrderedListActive = toolbarStatus.isOrderedListActive,
139
- isUnorderedListActive = toolbarStatus.isUnorderedListActive,
140
- isCheckListActive = toolbarStatus.isCheckListActive,
141
- isFormulaActive = toolbarStatus.isFormulaActive,
142
- isColumnActive = toolbarStatus.isColumnActive;
143
- var isListActive = isOrderedListActive || isUnorderedListActive || isCheckListActive;
144
- var sidePanelText = isShowSidePanel ? t('Hide_side_panel') : t('Show_side_panel');
145
- var _this$state = this.state,
146
- isShowLinkDialog = _this$state.isShowLinkDialog,
147
- isShowImageDialog = _this$state.isShowImageDialog,
148
- isShowFormulaDialog = _this$state.isShowFormulaDialog;
149
- var isHeadActive = toolbarStatus.headerType !== 'paragraph';
150
- return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
151
- className: 'sf-editor-toolbar ' + (this.props.isSimpleEditor ? '' : 'rich-menu')
152
- }, /*#__PURE__*/React.createElement("div", {
153
- className: 'button-container'
154
- }, /*#__PURE__*/React.createElement("div", {
155
- className: 'header-list-container'
156
- }, /*#__PURE__*/React.createElement(HeaderList, {
157
- disabled: isFormulaActive || isCodeActive || isColumnActive || isTableActive,
158
- headerType: toolbarStatus.headerType,
159
- onClickHeader: this.onClickHeader
160
- })), /*#__PURE__*/React.createElement(ButtonGroup, {
161
- className: 'editor-btn-group'
162
- }, /*#__PURE__*/React.createElement(ButtonItem, {
163
- disabled: isFormulaActive || isCodeActive || isColumnActive,
164
- isRichEditor: true,
165
- text: t('italic'),
166
- id: 'ITALICButton',
167
- icon: 'iconfont icon-italic',
168
- isActive: isItalicActive,
169
- onMouseDown: this.onClickMark('ITALIC')
170
- }), /*#__PURE__*/React.createElement(ButtonItem, {
171
- disabled: isFormulaActive || isCodeActive || isColumnActive,
172
- isRichEditor: true,
173
- text: t('bold'),
174
- id: 'BOLDButton',
175
- icon: 'iconfont icon-bold',
176
- isActive: isBoldActive,
177
- onMouseDown: this.onClickMark('BOLD')
178
- }), /*#__PURE__*/React.createElement(ButtonItem, {
179
- disabled: isFormulaActive || isCodeActive || isColumnActive,
180
- isRichEditor: true,
181
- text: t('code'),
182
- id: 'CODEButton',
183
- icon: 'iconfont icon-code',
184
- isActive: isInlineCodeActive,
185
- onMouseDown: this.onClickMark('CODE')
186
- }), /*#__PURE__*/React.createElement(ButtonItem, {
187
- disabled: isFormulaActive || isCodeActive || isColumnActive,
188
- isRichEditor: true,
189
- text: t('insert_link'),
190
- id: 'linkButton',
191
- icon: 'iconfont icon-link',
192
- isActive: isLinkActive,
193
- onMouseDown: this.onToggleLink
194
- })), /*#__PURE__*/React.createElement(ButtonGroup, {
195
- className: 'editor-btn-group'
196
- }, /*#__PURE__*/React.createElement(ButtonItem, {
197
- disabled: isFormulaActive || isTableActive || isColumnActive || isCodeActive,
198
- isRichEditor: true,
199
- text: t('quote'),
200
- id: 'block-quoteButton',
201
- icon: 'iconfont icon-quote-left',
202
- isActive: isBlockquoteActive,
203
- onMouseDown: this.onClickBlock('blockquote')
204
- }), /*#__PURE__*/React.createElement(ButtonItem, {
205
- disabled: isFormulaActive || isTableActive || isColumnActive || isCodeActive,
206
- isRichEditor: true,
207
- text: t('ordered_list'),
208
- id: 'ordered_listButton',
209
- icon: 'iconfont icon-list-ol',
210
- isActive: isOrderedListActive,
211
- onMouseDown: this.onClickBlock('ordered_list')
212
- }), /*#__PURE__*/React.createElement(ButtonItem, {
213
- disabled: isFormulaActive || isTableActive || isColumnActive || isCodeActive,
214
- isRichEditor: true,
215
- text: t('unordered_list'),
216
- id: 'unordered_listButton',
217
- icon: 'iconfont icon-list-ul',
218
- isActive: isUnorderedListActive,
219
- onMouseDown: this.onClickBlock('unordered_list')
220
- }), !canInsertColumn && /*#__PURE__*/React.createElement(ButtonItem, {
221
- disabled: isFormulaActive || isTableActive || isColumnActive || isCodeActive,
222
- isRichEditor: true,
223
- text: t('check_list_item'),
224
- id: 'checkListItemButton',
225
- icon: 'iconfont icon-check-square',
226
- isActive: isCheckListActive,
227
- onMouseDown: this.onClickCheckItem
228
- })), /*#__PURE__*/React.createElement(ButtonGroup, {
229
- className: 'editor-btn-group'
230
- }, /*#__PURE__*/React.createElement(ButtonItem, {
231
- disabled: isFormulaActive || isTableActive || isColumnActive || isHeadActive,
232
- isRichEditor: true,
233
- text: t('code_block'),
234
- id: 'codeButton',
235
- icon: 'iconfont icon-code-block',
236
- isActive: isCodeActive,
237
- onMouseDown: this.onClickBlock('code_block')
238
- }), /*#__PURE__*/React.createElement(InsertTable, {
239
- disabled: isFormulaActive || isCodeActive || isTableActive || isColumnActive,
240
- isRichEditor: true,
241
- text: t('insert_table'),
242
- id: 'tableButton',
243
- icon: 'iconfont icon-table',
244
- onAddTable: this.onAddTable
245
- }), window.canInsertFormula && /*#__PURE__*/React.createElement(ButtonItem, {
246
- disabled: isFormulaActive || isCodeActive || isTableActive || isColumnActive || isHeadActive || isListActive,
247
- isRichEditor: true,
248
- text: t('insert_formula'),
249
- id: 'formulaButton',
250
- icon: 'iconfont icon-formula',
251
- onMouseDown: this.onToggleFormulaDialog
252
- }), /*#__PURE__*/React.createElement(InsertImage, {
253
- disabled: isFormulaActive || isCodeActive || isColumnActive || isHeadActive,
254
- text: 'insert_image',
255
- id: 'insertImageButton',
256
- insertRepoFile: this.props.insertRepoFile,
257
- toolbarStatus: this.props.toolbarStatus,
258
- onInsertImage: this.onInsertImage,
259
- onToggleImageDialog: this.onToggleImageDialog
260
- }), canInsertColumn && /*#__PURE__*/React.createElement(ButtonItem, {
261
- disabled: isFormulaActive || isTableActive || isHeadActive,
262
- isRichEditor: true,
263
- text: t('Insert_column'),
264
- id: 'insertColumn',
265
- className: "svg-button",
266
- onMouseDown: this.onAddCustomColumn,
267
- isActive: isCodeActive,
268
- image: ColumnIcon
269
- })), isTableActive && /*#__PURE__*/React.createElement(TableGroup, {
270
- onRemoveTable: this.onRemoveTable,
271
- onInsertColumn: this.onInsertColumn,
272
- onRemoveColumn: this.onRemoveColumn,
273
- onInsertRow: this.onInsertRow,
274
- onRemoveRow: this.onRemoveRow,
275
- onSetAlign: this.onSetAlign
276
- }), /*#__PURE__*/React.createElement(ButtonGroup, {
277
- className: 'editor-btn-group'
278
- }, /*#__PURE__*/React.createElement(ButtonItem, {
279
- className: 'editor-clear-format',
280
- isRichEditor: true,
281
- text: t('Clear_format'),
282
- id: 'clearButton',
283
- icon: 'iconfont icon-clear-format',
284
- onMouseDown: this.onClearFormat
285
- }))), hasSidePanel && /*#__PURE__*/React.createElement("div", {
286
- className: "button-container"
287
- }, !this.props.isShowSidePanel && /*#__PURE__*/React.createElement(ButtonGroup, {
288
- className: "editor-btn-group position-absolute dropdown-menu-right"
289
- }, /*#__PURE__*/React.createElement(ButtonItem, {
290
- isRichEditor: true,
291
- text: sidePanelText,
292
- id: "showSidePanel",
293
- icon: "iconfont icon-angle-double-left",
294
- isActive: false,
295
- onMouseDown: this.props.toggleSidePanel
296
- })), this.props.isShowSidePanel && /*#__PURE__*/React.createElement(ButtonGroup, {
297
- className: "editor-btn-group position-absolute dropdown-menu-right"
298
- }, /*#__PURE__*/React.createElement(ButtonItem, {
299
- isRichEditor: true,
300
- text: sidePanelText,
301
- id: "hideSidePanel",
302
- icon: "iconfont icon-angle-double-right",
303
- isActive: false,
304
- onMouseDown: this.props.toggleSidePanel
305
- })))), isShowLinkDialog && /*#__PURE__*/React.createElement(AddLinkDialog, {
306
- toggleLinkDialog: this.onToggleLinkDialog
307
- }), isShowFormulaDialog && /*#__PURE__*/React.createElement(AddFormulaDialog, {
308
- toggleFormulaDialog: this.onToggleFormulaDialog
309
- }), isShowImageDialog && /*#__PURE__*/React.createElement(AddImageDialog, {
310
- insertImage: this.onInsertImage,
311
- onToggleImageDialog: this.onToggleImageDialog
312
- }));
313
- }
314
- }]);
315
- return Toolbar;
316
- }(React.Component);
317
- export default withTranslation('seafile-editor')(Toolbar);
@@ -1,24 +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
- var ButtonGroup = /*#__PURE__*/function (_React$PureComponent) {
7
- _inherits(ButtonGroup, _React$PureComponent);
8
- var _super = _createSuper(ButtonGroup);
9
- function ButtonGroup() {
10
- _classCallCheck(this, ButtonGroup);
11
- return _super.apply(this, arguments);
12
- }
13
- _createClass(ButtonGroup, [{
14
- key: "render",
15
- value: function render() {
16
- return /*#__PURE__*/React.createElement("div", {
17
- className: 'btn-group ' + this.props.className,
18
- role: 'group'
19
- }, this.props.children);
20
- }
21
- }]);
22
- return ButtonGroup;
23
- }(React.PureComponent);
24
- export default ButtonGroup;
@@ -1,129 +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
- var ButtonItem = /*#__PURE__*/function (_React$Component) {
9
- _inherits(ButtonItem, _React$Component);
10
- var _super = _createSuper(ButtonItem);
11
- function ButtonItem(props) {
12
- var _this;
13
- _classCallCheck(this, ButtonItem);
14
- _this = _super.call(this, props);
15
- _this.toggle = function () {
16
- var disabled = _this.props.disabled;
17
- if (disabled) return;
18
- var _this$state = _this.state,
19
- isFreezed = _this$state.isFreezed,
20
- tooltipOpen = _this$state.tooltipOpen;
21
- if (isFreezed && !tooltipOpen) return;
22
- _this.setState({
23
- tooltipOpen: !tooltipOpen,
24
- isFreezed: true
25
- });
26
- _this.timer = setTimeout(function () {
27
- _this.setState({
28
- isFreezed: false
29
- });
30
- }, 100);
31
- };
32
- _this.onClick = function (event) {
33
- if (!_this.props.disabled) {
34
- _this.props.onClick && _this.props.onClick(event);
35
- }
36
- };
37
- _this.onMouseDown = function (event) {
38
- if (!_this.props.disabled) {
39
- _this.props.onMouseDown(event);
40
- }
41
- };
42
- _this.getClassName = function () {
43
- var _this$props = _this.props,
44
- isRichEditor = _this$props.isRichEditor,
45
- className = _this$props.className,
46
- disabled = _this$props.disabled;
47
- var itemClass = 'btn btn-icon btn-secondary btn-active';
48
- if (!isRichEditor) return itemClass + ' ' + className;
49
- itemClass = "rich-icon-btn ".concat(disabled ? 'rich-icon-btn-disabled' : 'rich-icon-btn-hover');
50
- return itemClass + ' ' + className;
51
- };
52
- _this.state = {
53
- tooltipOpen: false,
54
- isFreezed: false
55
- };
56
- return _this;
57
- }
58
- _createClass(ButtonItem, [{
59
- key: "componentWillUnmount",
60
- value: function componentWillUnmount() {
61
- this.timer && clearTimeout(this.timer);
62
- }
63
- }, {
64
- key: "shouldComponentUpdate",
65
- value: function shouldComponentUpdate(nextProps, nextState) {
66
- var disabled = nextProps.disabled,
67
- isActive = nextProps.isActive;
68
- var _this$props2 = this.props,
69
- oldDisabled = _this$props2.disabled,
70
- oldIsActive = _this$props2.isActive;
71
- if (disabled !== oldDisabled) {
72
- this.setState({
73
- tooltipOpen: false
74
- });
75
- return true;
76
- }
77
- // only render iconButton when the button is active or show show tooltip
78
- var tooltipOpen = nextState.tooltipOpen;
79
- var oldTooltipOpen = this.state.tooltipOpen;
80
- if (tooltipOpen === oldTooltipOpen && isActive === oldIsActive) {
81
- return false;
82
- }
83
- return true;
84
- }
85
- }, {
86
- key: "render",
87
- value: function render() {
88
- var tooltipOpen = this.state.tooltipOpen;
89
- var _this$props3 = this.props,
90
- id = _this$props3.id,
91
- isActive = _this$props3.isActive,
92
- disabled = _this$props3.disabled,
93
- icon = _this$props3.icon,
94
- text = _this$props3.text,
95
- Image = _this$props3.image;
96
- var className = this.getClassName();
97
- var delay = {
98
- show: 0,
99
- hide: 0
100
- };
101
- return /*#__PURE__*/React.createElement("button", {
102
- type: "button",
103
- id: id,
104
- className: className,
105
- "data-active": isActive,
106
- disabled: disabled,
107
- onClick: this.onClick,
108
- onMouseDown: this.onMouseDown
109
- }, icon ? /*#__PURE__*/React.createElement("i", {
110
- className: icon
111
- }) : /*#__PURE__*/React.createElement(Image, {
112
- width: "13px",
113
- color: disabled ? '#999' : '#555'
114
- }), /*#__PURE__*/React.createElement(Tooltip, {
115
- target: id,
116
- isOpen: tooltipOpen,
117
- delay: delay,
118
- placement: "bottom",
119
- toggle: this.toggle
120
- }, text));
121
- }
122
- }]);
123
- return ButtonItem;
124
- }(React.Component);
125
- ButtonItem.defaultProps = {
126
- className: '',
127
- isActive: false
128
- };
129
- export default withTranslation('seafile-editor')(ButtonItem);