@seafile/seafile-editor 1.0.2 → 1.0.4
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.
- package/dist/constants/event-types.js +2 -8
- package/dist/constants/hot-keys.js +1 -7
- package/dist/containers/article-info/index.js +24 -34
- package/dist/containers/custom/get-event-transfer.js +10 -16
- package/dist/containers/custom/set-event-transfer.js +10 -16
- package/dist/containers/hotkeys-helper/classify-hotkeys.js +20 -25
- package/dist/containers/hotkeys-helper/index.js +32 -35
- package/dist/containers/loading/index.js +11 -32
- package/dist/containers/outline/index.js +41 -51
- package/dist/containers/outline/outline-item.js +15 -21
- package/dist/editors/plain-markdown-editor/code-mirror.js +51 -75
- package/dist/editors/plain-markdown-editor/index.js +90 -107
- package/dist/editors/simple-slate-editor /index.js +43 -57
- package/dist/editors/simple-slate-editor /with-props-editor.js +4 -10
- package/dist/editors/slate-editor/editor-help/index.js +24 -37
- package/dist/editors/slate-editor/index.js +50 -64
- package/dist/editors/slate-editor/with-props-editor.js +4 -10
- package/dist/editors/slate-viewer/index.js +25 -31
- package/dist/extension/commons/element-popover/index.js +30 -55
- package/dist/extension/commons/index.js +3 -26
- package/dist/extension/commons/menu/index.js +4 -21
- package/dist/extension/commons/menu/menu-drop-down.js +50 -63
- package/dist/extension/commons/menu/menu-group.js +4 -11
- package/dist/extension/commons/menu/menu-item.js +25 -30
- package/dist/extension/commons/tooltip/index.js +14 -19
- package/dist/extension/constants/element-types.js +22 -28
- package/dist/extension/constants/index.js +15 -37
- package/dist/extension/constants/keyboard.js +3 -9
- package/dist/extension/constants/menus-config.js +118 -105
- package/dist/extension/core/index.js +3 -38
- package/dist/extension/core/queries/index.js +209 -304
- package/dist/extension/core/transforms/focus-editor.js +7 -13
- package/dist/extension/core/transforms/index.js +4 -49
- package/dist/extension/core/transforms/move-children.js +18 -25
- package/dist/extension/core/transforms/remove-node-children.js +8 -27
- package/dist/extension/core/transforms/replace-node-children.js +14 -19
- package/dist/extension/core/utils/index.js +36 -44
- package/dist/extension/editor.js +8 -15
- package/dist/extension/index.js +7 -48
- package/dist/extension/plugins/blockquote/helpers.js +38 -57
- package/dist/extension/plugins/blockquote/index.js +8 -15
- package/dist/extension/plugins/blockquote/menu/index.js +20 -25
- package/dist/extension/plugins/blockquote/plugin.js +35 -41
- package/dist/extension/plugins/blockquote/render-elem.js +9 -14
- package/dist/extension/plugins/check-list/helper.js +14 -24
- package/dist/extension/plugins/check-list/index.js +10 -17
- package/dist/extension/plugins/check-list/menu/index.js +21 -29
- package/dist/extension/plugins/check-list/plugin.js +24 -26
- package/dist/extension/plugins/check-list/render-elem.js +22 -28
- package/dist/extension/plugins/clear-format/helpers.js +25 -47
- package/dist/extension/plugins/clear-format/menu/index.js +22 -29
- package/dist/extension/plugins/code-block/helpers.js +74 -126
- package/dist/extension/plugins/code-block/index.js +10 -18
- package/dist/extension/plugins/code-block/menu/index.js +20 -27
- package/dist/extension/plugins/code-block/plugin.js +123 -144
- package/dist/extension/plugins/code-block/render-elem/constant.js +15 -11
- package/dist/extension/plugins/code-block/render-elem/index.js +30 -39
- package/dist/extension/plugins/code-block/render-elem/language-selector.js +19 -27
- package/dist/extension/plugins/formula/helper.js +39 -45
- package/dist/extension/plugins/formula/index.js +10 -17
- package/dist/extension/plugins/formula/menu/formula-modal.js +37 -52
- package/dist/extension/plugins/formula/menu/index.js +34 -50
- package/dist/extension/plugins/formula/plugin.js +12 -14
- package/dist/extension/plugins/formula/render-elem.js +27 -33
- package/dist/extension/plugins/header/helper.js +35 -48
- package/dist/extension/plugins/header/index.js +10 -17
- package/dist/extension/plugins/header/menu/index.js +52 -66
- package/dist/extension/plugins/header/plugin.js +72 -83
- package/dist/extension/plugins/header/render-elem.js +15 -20
- package/dist/extension/plugins/image/helper.js +28 -37
- package/dist/extension/plugins/image/index.js +10 -17
- package/dist/extension/plugins/image/menu/image-menu-dialog.js +31 -42
- package/dist/extension/plugins/image/menu/image-menu-popover.js +35 -67
- package/dist/extension/plugins/image/menu/index.js +24 -34
- package/dist/extension/plugins/image/plugin.js +18 -18
- package/dist/extension/plugins/image/render-element/image-previewer.js +32 -42
- package/dist/extension/plugins/image/render-element/index.js +58 -74
- package/dist/extension/plugins/index.js +18 -94
- package/dist/extension/plugins/link/helper.js +102 -139
- package/dist/extension/plugins/link/index.js +10 -17
- package/dist/extension/plugins/link/menu/index.js +46 -62
- package/dist/extension/plugins/link/menu/link-modal.js +67 -87
- package/dist/extension/plugins/link/plugin.js +52 -56
- package/dist/extension/plugins/link/render-elem/index.js +39 -54
- package/dist/extension/plugins/link/render-elem/link-popover.js +38 -42
- package/dist/extension/plugins/list/constant.js +2 -8
- package/dist/extension/plugins/list/helpers.js +40 -54
- package/dist/extension/plugins/list/index.js +10 -17
- package/dist/extension/plugins/list/menu/index.js +23 -33
- package/dist/extension/plugins/list/plugin/index.js +28 -31
- package/dist/extension/plugins/list/plugin/insert-break-list.js +9 -15
- package/dist/extension/plugins/list/plugin/insert-fragment-list.js +86 -109
- package/dist/extension/plugins/list/plugin/normalize-list.js +31 -42
- package/dist/extension/plugins/list/plugin/on-tab-handle.js +35 -34
- package/dist/extension/plugins/list/queries/index.js +22 -30
- package/dist/extension/plugins/list/render-elem/index.js +27 -27
- package/dist/extension/plugins/list/transforms/index.js +11 -75
- package/dist/extension/plugins/list/transforms/insert-list-item.js +38 -47
- package/dist/extension/plugins/list/transforms/move-list-item-down.js +22 -32
- package/dist/extension/plugins/list/transforms/move-list-item-up.js +45 -56
- package/dist/extension/plugins/list/transforms/move-list-items-to-list.js +25 -31
- package/dist/extension/plugins/list/transforms/move-list-items.js +37 -44
- package/dist/extension/plugins/list/transforms/normalize-list-item.js +57 -81
- package/dist/extension/plugins/list/transforms/normalize-nested-list.js +17 -26
- package/dist/extension/plugins/list/transforms/remove-first-list-item.js +12 -19
- package/dist/extension/plugins/list/transforms/transforms-to-list.js +60 -84
- package/dist/extension/plugins/list/transforms/unwrap-list.js +20 -29
- package/dist/extension/plugins/node-id/constants.js +9 -15
- package/dist/extension/plugins/node-id/helpers.js +33 -35
- package/dist/extension/plugins/node-id/index.js +4 -11
- package/dist/extension/plugins/node-id/with-node-id.js +18 -26
- package/dist/extension/plugins/paragraph/helper.js +7 -13
- package/dist/extension/plugins/paragraph/index.js +8 -15
- package/dist/extension/plugins/paragraph/plugin.js +25 -27
- package/dist/extension/plugins/paragraph/render-elem.js +9 -14
- package/dist/extension/plugins/table/constant.js +3 -9
- package/dist/extension/plugins/table/helper.js +133 -154
- package/dist/extension/plugins/table/index.js +11 -19
- package/dist/extension/plugins/table/menu/index.js +26 -38
- package/dist/extension/plugins/table/menu/table-operator.js +62 -77
- package/dist/extension/plugins/table/menu/table-size-selector.js +41 -62
- package/dist/extension/plugins/table/model.js +39 -41
- package/dist/extension/plugins/table/plugin.js +95 -102
- package/dist/extension/plugins/table/render-elem/context-menu.js +42 -65
- package/dist/extension/plugins/table/render-elem/index.js +85 -93
- package/dist/extension/plugins/table/table-operations.js +101 -118
- package/dist/extension/plugins/text-style/helpers.js +18 -28
- package/dist/extension/plugins/text-style/index.js +8 -15
- package/dist/extension/plugins/text-style/menu/index.js +19 -25
- package/dist/extension/plugins/text-style/plugin.js +16 -21
- package/dist/extension/plugins/text-style/render-elem.js +28 -33
- package/dist/extension/render/render-element.js +26 -47
- package/dist/extension/render/render-leaf.js +9 -18
- package/dist/extension/toolbar/header-toolbar/index.js +66 -84
- package/dist/extension/toolbar/index.js +2 -13
- package/dist/extension/toolbar/user-help/shortcut-dialog.js +108 -131
- package/dist/hooks/use-mathjax.js +9 -20
- package/dist/hooks/use-scroll-context.js +7 -12
- package/dist/hooks/use-selection-update.js +9 -21
- package/dist/index.js +9 -80
- package/dist/pages/markdown-editor.js +30 -43
- package/dist/pages/markdown-view.js +25 -37
- package/dist/pages/rich-markdown-editor.js +54 -67
- package/dist/pages/simple-editor.js +29 -42
- package/dist/slate-convert/html-to-slate/constants.js +26 -32
- package/dist/slate-convert/html-to-slate/helper.js +1 -7
- package/dist/slate-convert/html-to-slate/index.js +44 -51
- package/dist/slate-convert/html-to-slate/rules/blockquote.js +10 -15
- package/dist/slate-convert/html-to-slate/rules/check-list.js +10 -15
- package/dist/slate-convert/html-to-slate/rules/code-block.js +40 -51
- package/dist/slate-convert/html-to-slate/rules/header.js +11 -16
- package/dist/slate-convert/html-to-slate/rules/image.js +10 -15
- package/dist/slate-convert/html-to-slate/rules/index.js +11 -18
- package/dist/slate-convert/html-to-slate/rules/link.js +11 -16
- package/dist/slate-convert/html-to-slate/rules/list.js +21 -26
- package/dist/slate-convert/html-to-slate/rules/paragraph.js +10 -15
- package/dist/slate-convert/html-to-slate/rules/table.js +14 -19
- package/dist/slate-convert/html-to-slate/rules/text.js +14 -19
- package/dist/slate-convert/index.js +8 -34
- package/dist/slate-convert/md-to-html/index.js +26 -31
- package/dist/slate-convert/md-to-html/sanitize-schema.js +5 -12
- package/dist/slate-convert/md-to-slate/index.js +17 -23
- package/dist/slate-convert/md-to-slate/transform.js +183 -175
- package/dist/slate-convert/slate-to-md/index.js +14 -20
- package/dist/slate-convert/slate-to-md/transform.js +76 -87
- package/dist/utils/common.js +8 -15
- package/dist/utils/deserialize-html.js +118 -166
- package/dist/utils/dom-utils.js +18 -22
- package/dist/utils/event-bus.js +27 -47
- package/dist/utils/event-handler.js +29 -38
- package/dist/utils/object-utils.js +39 -62
- package/package.json +5 -4
|
@@ -1,98 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}), (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _constants.MENUS_CONFIG_MAP[_constants.TABLE_SUBMENU_MAP.TABLE_ALIGN_CENTER]), {}, {
|
|
24
|
-
handleClick: function handleClick(item) {
|
|
25
|
-
return (0, _tableOperations.changeCellAlign)(editor, _constants.TEXT_ALIGN.CENTER);
|
|
26
|
-
}
|
|
27
|
-
}), (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _constants.MENUS_CONFIG_MAP[_constants.TABLE_SUBMENU_MAP.TABLE_ALIGN_RIGHT]), {}, {
|
|
28
|
-
handleClick: function handleClick(item) {
|
|
29
|
-
return (0, _tableOperations.changeCellAlign)(editor, _constants.TEXT_ALIGN.RIGHT);
|
|
30
|
-
}
|
|
31
|
-
})];
|
|
32
|
-
}, [editor]);
|
|
33
|
-
return /*#__PURE__*/_react.default.createElement(_menuDropDown.default, Object.assign({
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import MenuDropDown from '../../../commons/menu/menu-drop-down';
|
|
3
|
+
import { MENUS_CONFIG_MAP, TABLE_SUBMENU_MAP, TEXT_ALIGN } from '../../../constants';
|
|
4
|
+
import MenuItem from '../../../commons/menu/menu-item';
|
|
5
|
+
import { changeCellAlign, insertColumn, insertRow, removeColumn, removeRow, removeTable } from '../table-operations';
|
|
6
|
+
const AlignmentDropDown = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
editor,
|
|
9
|
+
readonly
|
|
10
|
+
} = _ref;
|
|
11
|
+
const alignmentOperationDropDownList = useMemo(() => [{
|
|
12
|
+
...MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_ALIGN_LEFT],
|
|
13
|
+
handleClick: item => changeCellAlign(editor, TEXT_ALIGN.LEFT)
|
|
14
|
+
}, {
|
|
15
|
+
...MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_ALIGN_CENTER],
|
|
16
|
+
handleClick: item => changeCellAlign(editor, TEXT_ALIGN.CENTER)
|
|
17
|
+
}, {
|
|
18
|
+
...MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_ALIGN_RIGHT],
|
|
19
|
+
handleClick: item => changeCellAlign(editor, TEXT_ALIGN.RIGHT)
|
|
20
|
+
}], [editor]);
|
|
21
|
+
return /*#__PURE__*/React.createElement(MenuDropDown, Object.assign({
|
|
34
22
|
editor: editor,
|
|
35
23
|
readonly: readonly,
|
|
36
24
|
isDisabled: false,
|
|
37
25
|
dropDownList: alignmentOperationDropDownList,
|
|
38
26
|
isShowListItemIcon: true
|
|
39
|
-
},
|
|
27
|
+
}, MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_ALIGN_LEFT]));
|
|
40
28
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, [editor]);
|
|
55
|
-
return /*#__PURE__*/_react.default.createElement(_menuDropDown.default, Object.assign({
|
|
29
|
+
const ColumnOperationDropDownList = _ref2 => {
|
|
30
|
+
let {
|
|
31
|
+
editor,
|
|
32
|
+
readonly
|
|
33
|
+
} = _ref2;
|
|
34
|
+
const columnOperationDropDownList = useMemo(() => [{
|
|
35
|
+
...MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_INSERT_COLUMN],
|
|
36
|
+
handleClick: item => insertColumn(editor)
|
|
37
|
+
}, {
|
|
38
|
+
...MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_REMOVE_COLUMN],
|
|
39
|
+
handleClick: item => removeColumn(editor)
|
|
40
|
+
}], [editor]);
|
|
41
|
+
return /*#__PURE__*/React.createElement(MenuDropDown, Object.assign({
|
|
56
42
|
editor: editor,
|
|
57
43
|
readonly: readonly,
|
|
58
44
|
isDisabled: false,
|
|
59
45
|
dropDownList: columnOperationDropDownList
|
|
60
|
-
},
|
|
46
|
+
}, MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_INSERT_COLUMN]));
|
|
61
47
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}, [editor]);
|
|
76
|
-
return /*#__PURE__*/_react.default.createElement(_menuDropDown.default, Object.assign({
|
|
48
|
+
const RowOperationDropDownList = _ref3 => {
|
|
49
|
+
let {
|
|
50
|
+
editor,
|
|
51
|
+
readonly
|
|
52
|
+
} = _ref3;
|
|
53
|
+
const rowOperationDropDownList = useMemo(() => [{
|
|
54
|
+
...MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_INSERT_ROW],
|
|
55
|
+
handleClick: item => insertRow(editor)
|
|
56
|
+
}, {
|
|
57
|
+
...MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_REMOVE_ROW],
|
|
58
|
+
handleClick: item => removeRow(editor)
|
|
59
|
+
}], [editor]);
|
|
60
|
+
return /*#__PURE__*/React.createElement(MenuDropDown, Object.assign({
|
|
77
61
|
editor: editor,
|
|
78
62
|
readonly: readonly,
|
|
79
63
|
isDisabled: false,
|
|
80
64
|
dropDownList: rowOperationDropDownList
|
|
81
|
-
},
|
|
65
|
+
}, MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_INSERT_ROW]));
|
|
82
66
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
67
|
+
const RemoveTableMenu = _ref4 => {
|
|
68
|
+
let {
|
|
69
|
+
editor,
|
|
70
|
+
readonly,
|
|
71
|
+
className,
|
|
72
|
+
isRichEditor
|
|
73
|
+
} = _ref4;
|
|
74
|
+
return /*#__PURE__*/React.createElement(MenuItem, Object.assign({
|
|
89
75
|
isRichEditor: isRichEditor,
|
|
90
76
|
className: className,
|
|
91
77
|
disabled: false,
|
|
92
78
|
isActive: false,
|
|
93
|
-
onMouseDown:
|
|
94
|
-
return (0, _tableOperations.removeTable)(editor);
|
|
95
|
-
},
|
|
79
|
+
onMouseDown: () => removeTable(editor),
|
|
96
80
|
editor: editor
|
|
97
|
-
},
|
|
98
|
-
};
|
|
81
|
+
}, MENUS_CONFIG_MAP[TABLE_SUBMENU_MAP.TABLE_DELETE_TABLE]));
|
|
82
|
+
};
|
|
83
|
+
export { AlignmentDropDown, ColumnOperationDropDownList, RowOperationDropDownList, RemoveTableMenu };
|
|
@@ -1,37 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
setSelectedGridInfo = _useState2[1];
|
|
23
|
-
var _useState3 = (0, _react.useState)({
|
|
24
|
-
row: 4,
|
|
25
|
-
column: 4
|
|
26
|
-
}),
|
|
27
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
28
|
-
showingGridInfo = _useState4[0],
|
|
29
|
-
setShowingGridInfo = _useState4[1];
|
|
30
|
-
var preRenderTableGrid = (0, _react.useCallback)(function (rowIndex, columnIndex) {
|
|
31
|
-
var selectedRowNums = rowIndex + 1;
|
|
32
|
-
var selectedColumnNums = columnIndex + 1;
|
|
33
|
-
var preRenderRowNum = selectedRowNums + 1;
|
|
34
|
-
var preRenderColumnNum = selectedColumnNums + 1;
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { insertTable } from '../helper';
|
|
4
|
+
import './style.css';
|
|
5
|
+
const TableSizeSelector = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
editor
|
|
8
|
+
} = _ref;
|
|
9
|
+
const [selectedGridInfo, setSelectedGridInfo] = useState({
|
|
10
|
+
row: 0,
|
|
11
|
+
column: 0
|
|
12
|
+
});
|
|
13
|
+
const [showingGridInfo, setShowingGridInfo] = useState({
|
|
14
|
+
row: 4,
|
|
15
|
+
column: 4
|
|
16
|
+
});
|
|
17
|
+
const preRenderTableGrid = useCallback((rowIndex, columnIndex) => {
|
|
18
|
+
const selectedRowNums = rowIndex + 1;
|
|
19
|
+
const selectedColumnNums = columnIndex + 1;
|
|
20
|
+
let preRenderRowNum = selectedRowNums + 1;
|
|
21
|
+
let preRenderColumnNum = selectedColumnNums + 1;
|
|
35
22
|
if (preRenderRowNum < 4) {
|
|
36
23
|
preRenderRowNum = 4;
|
|
37
24
|
} else if (preRenderRowNum > 10) {
|
|
@@ -51,50 +38,42 @@ var TableSizeSelector = function TableSizeSelector(_ref) {
|
|
|
51
38
|
column: preRenderColumnNum
|
|
52
39
|
});
|
|
53
40
|
}, []);
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
const handleClickTableCell = useCallback(() => {
|
|
42
|
+
insertTable(editor, selectedGridInfo.row, selectedGridInfo.column);
|
|
56
43
|
}, [editor, selectedGridInfo]);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
const generateTableGrid = useCallback((rowNum, columnNum) => {
|
|
45
|
+
const {
|
|
46
|
+
row: selectedRowIndex,
|
|
47
|
+
column: selectedColumnIndex
|
|
48
|
+
} = selectedGridInfo;
|
|
49
|
+
const rowElements = [];
|
|
50
|
+
for (let rowIndex = 0; rowIndex < rowNum; rowIndex++) {
|
|
51
|
+
const columnElements = [];
|
|
52
|
+
for (let columnIndex = 0; columnIndex < columnNum; columnIndex++) {
|
|
53
|
+
const isCellSelected = selectedRowIndex > rowIndex && selectedColumnIndex > columnIndex;
|
|
54
|
+
columnElements.push( /*#__PURE__*/React.createElement("div", {
|
|
66
55
|
onClick: handleClickTableCell,
|
|
67
|
-
onMouseEnter:
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
className: (0, _classnames.default)('sf-table-selector-cell', {
|
|
56
|
+
onMouseEnter: () => preRenderTableGrid(rowIndex, columnIndex),
|
|
57
|
+
className: classNames('sf-table-selector-cell', {
|
|
71
58
|
selected: isCellSelected
|
|
72
59
|
}),
|
|
73
60
|
key: "".concat(rowIndex, "-").concat(columnIndex)
|
|
74
61
|
}));
|
|
75
|
-
};
|
|
76
|
-
for (var columnIndex = 0; columnIndex < columnNum; columnIndex++) {
|
|
77
|
-
_loop2(columnIndex);
|
|
78
62
|
}
|
|
79
|
-
rowElements.push( /*#__PURE__*/
|
|
63
|
+
rowElements.push( /*#__PURE__*/React.createElement("div", {
|
|
80
64
|
className: "sf-table-row",
|
|
81
65
|
key: rowIndex
|
|
82
66
|
}, columnElements));
|
|
83
|
-
};
|
|
84
|
-
for (var rowIndex = 0; rowIndex < rowNum; rowIndex++) {
|
|
85
|
-
_loop(rowIndex);
|
|
86
67
|
}
|
|
87
68
|
return rowElements;
|
|
88
69
|
}, [handleClickTableCell, preRenderTableGrid, selectedGridInfo]);
|
|
89
70
|
|
|
90
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, [generateTableGrid]);
|
|
94
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
+
const tableGridElement = useMemo(() => generateTableGrid(showingGridInfo.row, showingGridInfo.column), [generateTableGrid]);
|
|
73
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
95
74
|
className: "sf-table-size-selector-card"
|
|
96
|
-
}, /*#__PURE__*/
|
|
75
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
97
76
|
className: "sf-table-grid-info"
|
|
98
77
|
}, "".concat(selectedGridInfo.row, " x ").concat(selectedGridInfo.column)), tableGridElement);
|
|
99
78
|
};
|
|
100
|
-
|
|
79
|
+
export default TableSizeSelector;
|
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { generateElement } from '../../core';
|
|
2
|
+
import { TABLE, TABLE_CELL, TABLE_ROW } from '../../constants/element-types';
|
|
3
|
+
import { TEXT_ALIGN } from '../../constants';
|
|
2
4
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateTableRow = exports.generateTableCell = exports.generateTable = void 0;
|
|
7
|
-
var _core = require("../../core");
|
|
8
|
-
var _elementTypes = require("../../constants/element-types");
|
|
9
|
-
var _constants = require("../../constants");
|
|
10
5
|
/**
|
|
11
6
|
* @param {Object} options
|
|
12
7
|
* @param {Node[] | String} [options.childrenOrText = ''] If provide a string,that will generate a text node as children automatically
|
|
13
8
|
* @param {keyof TEXT_ALIGN} [options.align = TEXT_ALIGN.left]
|
|
14
9
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
align =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
childrenOrText
|
|
10
|
+
const generateTableCell = function () {
|
|
11
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
|
+
const {
|
|
13
|
+
align = TEXT_ALIGN.LEFT,
|
|
14
|
+
childrenOrText = ''
|
|
15
|
+
} = options;
|
|
16
|
+
return generateElement(TABLE_CELL, {
|
|
17
|
+
childrenOrText,
|
|
23
18
|
props: {
|
|
24
|
-
align
|
|
19
|
+
align
|
|
25
20
|
}
|
|
26
21
|
});
|
|
27
22
|
};
|
|
@@ -31,29 +26,30 @@ var generateTableCell = exports.generateTableCell = function generateTableCell()
|
|
|
31
26
|
* @param {Node[] | String} [options.childrenOrText = ''] If provide a string,that will generate a text node as children automatically
|
|
32
27
|
* @param {number | undefined} columnNum If provide a number,that will generate a table row with the number of cells,or will fill the childrenOrText as cells,or will generate a empty cell(if not provide childrenOrText)
|
|
33
28
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
const generateTableRow = options => {
|
|
30
|
+
const {
|
|
31
|
+
columnNum
|
|
32
|
+
} = options;
|
|
33
|
+
let {
|
|
34
|
+
childrenOrText = ''
|
|
35
|
+
} = options;
|
|
36
|
+
let cells = [];
|
|
39
37
|
if (columnNum) {
|
|
40
38
|
cells = Array.from({
|
|
41
39
|
length: columnNum
|
|
42
|
-
},
|
|
43
|
-
return generateTableCell();
|
|
44
|
-
});
|
|
40
|
+
}, () => generateTableCell());
|
|
45
41
|
} else {
|
|
46
42
|
// If not type of string,we'll consider it as a cell array,or throw an error
|
|
47
43
|
if (typeof childrenOrText === 'string') {
|
|
48
44
|
childrenOrText = [generateTableCell({
|
|
49
|
-
childrenOrText
|
|
45
|
+
childrenOrText
|
|
50
46
|
})];
|
|
51
47
|
}
|
|
52
48
|
if (!Array.isArray(childrenOrText)) {
|
|
53
49
|
throw Error('childrenOrText must be a string or a Node array!');
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
|
-
return
|
|
52
|
+
return generateElement(TABLE_ROW, {
|
|
57
53
|
childrenOrText: columnNum ? cells : childrenOrText
|
|
58
54
|
});
|
|
59
55
|
};
|
|
@@ -64,32 +60,34 @@ var generateTableRow = exports.generateTableRow = function generateTableRow(opti
|
|
|
64
60
|
* @param {number | undefined} rowNum If provide a number,that will generate a table with the number of rows,or will fill the childrenOrText as rows,or will generate a empty row(if not provide childrenOrText)
|
|
65
61
|
* @param {number | undefined} columnNum If provide a number,that will generate a table row with the number of cells,or will fill the childrenOrText as cells,or will generate a empty cell(if not provide childrenOrText)
|
|
66
62
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
const generateTable = options => {
|
|
64
|
+
const {
|
|
65
|
+
rowNum,
|
|
66
|
+
columnNum
|
|
67
|
+
} = options;
|
|
68
|
+
let {
|
|
69
|
+
childrenOrText = ''
|
|
70
|
+
} = options;
|
|
71
|
+
let rows = [];
|
|
73
72
|
if (rowNum) {
|
|
74
73
|
rows = Array.from({
|
|
75
74
|
length: rowNum
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
80
|
-
});
|
|
75
|
+
}, () => generateTableRow({
|
|
76
|
+
columnNum
|
|
77
|
+
}));
|
|
81
78
|
} else {
|
|
82
79
|
// If not type of string,we'll consider it as a row array,or throw an error
|
|
83
80
|
if (typeof childrenOrText === 'string') {
|
|
84
81
|
childrenOrText = [generateTableRow({
|
|
85
|
-
childrenOrText
|
|
82
|
+
childrenOrText
|
|
86
83
|
})];
|
|
87
84
|
}
|
|
88
85
|
if (!Array.isArray(childrenOrText)) {
|
|
89
86
|
throw Error('childrenOrText must be a string or a Node array!');
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
|
-
return
|
|
89
|
+
return generateElement(TABLE, {
|
|
93
90
|
childrenOrText: rowNum ? rows : childrenOrText
|
|
94
91
|
});
|
|
95
|
-
};
|
|
92
|
+
};
|
|
93
|
+
export { generateTableCell, generateTableRow, generateTable };
|