@seafile/seafile-editor 1.0.117-alpha.21 → 1.0.117-alpha.22
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 +1 -3
- package/dist/containers/article-info/index.js +32 -76
- package/dist/containers/article-info/style.css +15 -89
- package/dist/containers/hotkeys-helper/style.css +1 -4
- package/dist/containers/outline/index.js +0 -9
- package/dist/containers/outline/style.css +0 -2
- package/dist/editors/simple-slate-editor/style.css +1 -1
- package/dist/editors/slate-editor/editor-help/index.js +4 -7
- package/dist/editors/slate-editor/editor-help/style.css +3 -3
- package/dist/editors/slate-editor/style.css +0 -8
- package/dist/extension/toolbar/header-toolbar/index.js +6 -1
- package/package.json +1 -1
- package/dist/containers/article-info/resize-width/index.js +0 -133
- package/dist/containers/article-info/resize-width/style.css +0 -37
|
@@ -11,12 +11,10 @@ const INTERNAL_EVENTS = exports.INTERNAL_EVENTS = {
|
|
|
11
11
|
ON_CLOSE_LINK_POPOVER: 'on_close_link_popover',
|
|
12
12
|
ON_OPEN_FORMULA_DIALOG: 'on_open_formula_dialog',
|
|
13
13
|
ON_SELECT_ALL_CELL: 'on_select_all_cell',
|
|
14
|
-
ON_TOGGLE_IMAGE_POPOVER: 'on_toggle_image_popover'
|
|
15
|
-
OUTLINE_STATE_CHANGED: 'outline_state_changed'
|
|
14
|
+
ON_TOGGLE_IMAGE_POPOVER: 'on_toggle_image_popover'
|
|
16
15
|
};
|
|
17
16
|
const EXTERNAL_EVENTS = exports.EXTERNAL_EVENTS = {
|
|
18
17
|
ON_HELP_INFO_TOGGLE: 'on_help_info_toggle',
|
|
19
|
-
ON_ARTICLE_INFO_TOGGLE: 'on_article_info_toggle',
|
|
20
18
|
ON_LINK_CLICK: 'on_link_click',
|
|
21
19
|
ON_INSERT_IMAGE: 'on_insert_image',
|
|
22
20
|
INSERT_IMAGE: 'insert_image'
|
|
@@ -7,92 +7,48 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = ArticleInfo;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _outline = _interopRequireDefault(require("../outline"));
|
|
10
11
|
var _slateReact = require("slate-react");
|
|
11
|
-
var _resizeWidth = _interopRequireDefault(require("./resize-width"));
|
|
12
|
-
var _eventBus = _interopRequireDefault(require("../../utils/event-bus"));
|
|
13
|
-
var _eventTypes = require("../../constants/event-types");
|
|
14
12
|
require("./style.css");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = window.app.pageOptions;
|
|
13
|
+
const TAB_TYPES = {
|
|
14
|
+
OUTLINE: 'outline',
|
|
15
|
+
FILE_DETAIL: 'file_detail'
|
|
16
|
+
};
|
|
20
17
|
function ArticleInfo(_ref) {
|
|
21
18
|
let {
|
|
22
19
|
children
|
|
23
20
|
} = _ref;
|
|
24
21
|
const editor = (0, _slateReact.useSlateStatic)();
|
|
25
|
-
const [
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} else if (style.width > MAX_PANEL_WIDTH) {
|
|
35
|
-
style.width = MAX_PANEL_WIDTH;
|
|
36
|
-
}
|
|
37
|
-
return style;
|
|
38
|
-
}, [width]);
|
|
39
|
-
const resizeWidth = (0, _react.useCallback)(width => {
|
|
40
|
-
console.log(width);
|
|
41
|
-
if (width >= MIN_PANEL_WIDTH && width <= MAX_PANEL_WIDTH) {
|
|
42
|
-
setWidth(width);
|
|
43
|
-
}
|
|
44
|
-
}, []);
|
|
45
|
-
const resizeWidthEnd = (0, _react.useCallback)(width => {
|
|
46
|
-
const panelWidth = JSON.parse(window.localStorage.getItem('sf-editor-panel-width') || '{}');
|
|
47
|
-
window.localStorage.setItem('sf-editor-panel-width', JSON.stringify({
|
|
48
|
-
...panelWidth,
|
|
49
|
-
width
|
|
50
|
-
}));
|
|
51
|
-
}, []);
|
|
52
|
-
(0, _react.useEffect)(() => {
|
|
53
|
-
const panelWidth = JSON.parse(window.localStorage.getItem('sf-editor-panel-width', '{}')) || {};
|
|
54
|
-
const width = Math.max(MIN_PANEL_WIDTH, Math.min(parseInt(panelWidth.width, 10) || MAX_PANEL_WIDTH, MAX_PANEL_WIDTH));
|
|
55
|
-
setWidth(width);
|
|
56
|
-
}, []);
|
|
57
|
-
const onClose = () => {
|
|
58
|
-
setIsShown(false);
|
|
59
|
-
};
|
|
60
|
-
(0, _react.useEffect)(() => {
|
|
61
|
-
const eventBus = _eventBus.default.getInstance();
|
|
62
|
-
// const unsubscribeArticleInfo = eventBus.subscribe(INTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, updateArticleInfoState);
|
|
63
|
-
const handleArticleInfoToggle = state => {
|
|
64
|
-
setIsShown(state);
|
|
65
|
-
};
|
|
66
|
-
const unsubscribeArticleInfo = eventBus.subscribe(_eventTypes.EXTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, handleArticleInfoToggle);
|
|
67
|
-
return () => {
|
|
68
|
-
// unsubscribeHelpInfo();
|
|
69
|
-
unsubscribeArticleInfo();
|
|
70
|
-
};
|
|
71
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
-
}, []);
|
|
73
|
-
console.log(111111);
|
|
22
|
+
const [activeTab, setActiveTab] = (0, _react.useState)(TAB_TYPES.OUTLINE);
|
|
23
|
+
const onOutlineClick = (0, _react.useCallback)(() => {
|
|
24
|
+
if (activeTab === TAB_TYPES.OUTLINE) return;
|
|
25
|
+
setActiveTab(TAB_TYPES.OUTLINE);
|
|
26
|
+
}, [activeTab]);
|
|
27
|
+
const onDetailClick = (0, _react.useCallback)(() => {
|
|
28
|
+
if (activeTab === TAB_TYPES.FILE_DETAIL) return;
|
|
29
|
+
setActiveTab(TAB_TYPES.FILE_DETAIL);
|
|
30
|
+
}, [activeTab]);
|
|
74
31
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
75
|
-
className: "sf-article-info-container-wrapper",
|
|
76
|
-
style: containerWrapperStyle
|
|
77
|
-
}, /*#__PURE__*/_react.default.createElement(_resizeWidth.default, {
|
|
78
|
-
minWidth: MIN_PANEL_WIDTH,
|
|
79
|
-
maxWidth: MAX_PANEL_WIDTH,
|
|
80
|
-
resizeWidth: resizeWidth,
|
|
81
|
-
resizeWidthEnd: resizeWidthEnd
|
|
82
|
-
}), isShown && /*#__PURE__*/_react.default.createElement("div", {
|
|
83
32
|
className: "sf-article-info-container"
|
|
84
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement("ul", {
|
|
85
34
|
className: "sf-article-info-nav nav"
|
|
86
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement("li", {
|
|
87
36
|
className: "nav-item"
|
|
88
|
-
}, /*#__PURE__*/_react.default.createElement("
|
|
89
|
-
className: "
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
37
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
38
|
+
className: "nav-link ".concat(activeTab === TAB_TYPES.OUTLINE && 'active'),
|
|
39
|
+
onClick: onOutlineClick
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
41
|
+
className: "iconfont icon-list-ul"
|
|
42
|
+
}))), /*#__PURE__*/_react.default.createElement("li", {
|
|
43
|
+
className: "nav-item"
|
|
44
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
45
|
+
className: "nav-link ".concat(activeTab === TAB_TYPES.FILE_DETAIL && 'active'),
|
|
46
|
+
onClick: onDetailClick
|
|
47
|
+
}, /*#__PURE__*/_react.default.createElement("i", {
|
|
48
|
+
className: 'iconfont icon-info-circle'
|
|
49
|
+
})))), /*#__PURE__*/_react.default.createElement("div", {
|
|
96
50
|
className: "sf-article-info-content"
|
|
97
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
51
|
+
}, activeTab === TAB_TYPES.OUTLINE && /*#__PURE__*/_react.default.createElement(_outline.default, {
|
|
52
|
+
editor: editor
|
|
53
|
+
}), activeTab === TAB_TYPES.FILE_DETAIL && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children)));
|
|
98
54
|
}
|
|
@@ -1,51 +1,25 @@
|
|
|
1
|
-
.sf-article-info-container-wrapper {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: row;
|
|
4
|
-
max-width: 620px;
|
|
5
|
-
min-width: 360px;
|
|
6
|
-
position: relative;
|
|
7
|
-
flex-basis: 620px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
1
|
.sf-article-info-container {
|
|
11
|
-
flex: 1
|
|
12
|
-
width: auto;
|
|
13
|
-
height: 100%;
|
|
14
|
-
overflow: auto;
|
|
15
|
-
border-left: 1px solid #d8d8d8;
|
|
16
|
-
background-color: #fff;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.sf-article-info-container .nav {
|
|
20
|
-
position: relative;
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: space-between;
|
|
24
|
-
line-height: 2.5rem;
|
|
25
|
-
border-bottom: 1px solid #e8e8e8;
|
|
26
|
-
height: 48px;
|
|
27
|
-
padding: 8px 16px;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.nav-control {
|
|
31
|
-
height: 24px;
|
|
32
|
-
width: 24px;
|
|
2
|
+
flex: 1;
|
|
33
3
|
display: flex;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
background-color: #f5f5f5;
|
|
6
|
+
user-select: none;
|
|
7
|
+
min-height: 0;
|
|
37
8
|
}
|
|
38
9
|
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
10
|
+
.sf-article-info-container .nav {
|
|
11
|
+
padding: 10px 0;
|
|
12
|
+
min-width: 125px;
|
|
13
|
+
height: 36px;
|
|
14
|
+
border-bottom: 1px solid #eee;
|
|
15
|
+
background-color: #fff;
|
|
16
|
+
justify-content: space-around;
|
|
17
|
+
flex-wrap: nowrap;
|
|
18
|
+
flex-shrink: 0;
|
|
42
19
|
}
|
|
43
20
|
|
|
44
21
|
.sf-article-info-container .nav .nav-item {
|
|
45
|
-
|
|
46
|
-
flex: 1;
|
|
47
|
-
align-items: center;
|
|
48
|
-
width: 0;
|
|
22
|
+
padding: 0 0.75rem;
|
|
49
23
|
}
|
|
50
24
|
|
|
51
25
|
.sf-article-info-container .nav .nav-link {
|
|
@@ -78,51 +52,3 @@
|
|
|
78
52
|
.sf-article-info-container .sf-article-info-content:hover {
|
|
79
53
|
overflow: auto;
|
|
80
54
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
.detail-header {
|
|
86
|
-
position: relative;
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
justify-content: space-between;
|
|
90
|
-
line-height: 2.5rem;
|
|
91
|
-
border-bottom: 1px solid #e8e8e8;
|
|
92
|
-
height: 48px;
|
|
93
|
-
padding: 8px 16px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.detail-header .detail-title {
|
|
97
|
-
display: flex;
|
|
98
|
-
flex: 1;
|
|
99
|
-
align-items: center;
|
|
100
|
-
width: 0; /* prevent strut flex layout */
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.detail-header .detail-title .name {
|
|
104
|
-
margin: 0 0.5rem 0 6px;
|
|
105
|
-
line-height: 1.5rem;
|
|
106
|
-
vertical-align: middle;
|
|
107
|
-
font-size: 1rem;
|
|
108
|
-
color: #212529;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.detail-header .detail-control {
|
|
112
|
-
height: 24px;
|
|
113
|
-
width: 24px;
|
|
114
|
-
display: flex;
|
|
115
|
-
align-items: center;
|
|
116
|
-
justify-content: center;
|
|
117
|
-
cursor: pointer;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.detail-header .detail-control .detail-control-close {
|
|
121
|
-
font-size: 16px;
|
|
122
|
-
fill: #666;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.detail-header .detail-control:hover {
|
|
126
|
-
background-color: #EFEFEF;
|
|
127
|
-
border-radius: 3px;
|
|
128
|
-
}
|
|
@@ -69,21 +69,12 @@ const Outline = _ref => {
|
|
|
69
69
|
};
|
|
70
70
|
}, [handleScroll, scrollRef]);
|
|
71
71
|
const toggleShow = (0, _react.useCallback)(() => {
|
|
72
|
-
// updateOutlineState(!isShown);
|
|
73
|
-
// const TAB_TYPES = { OUTLINE: 'outline'};
|
|
74
|
-
// if (activeTab === TAB_TYPES.OUTLINE)
|
|
75
|
-
|
|
76
|
-
// setIsShown(!isShown);
|
|
77
|
-
// const eventBus =EventBus.getInstance();
|
|
78
|
-
// eventBus.dispatch(INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, isShown)
|
|
79
72
|
setIsShown(prevIsShown => {
|
|
80
73
|
const newIsShown = !prevIsShown;
|
|
81
74
|
setTimeout(() => {
|
|
82
75
|
const eventBus = _eventBus.default.getInstance();
|
|
83
76
|
eventBus.dispatch(_eventTypes.INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, newIsShown);
|
|
84
77
|
}, 0);
|
|
85
|
-
// const eventBus = EventBus.getInstance();
|
|
86
|
-
// eventBus.dispatch(INTERNAL_EVENTS.OUTLINE_STATE_CHANGED, newIsShown);
|
|
87
78
|
return newIsShown;
|
|
88
79
|
});
|
|
89
80
|
}, []);
|
|
@@ -25,27 +25,24 @@ function EditorHelp(_ref) {
|
|
|
25
25
|
}, []);
|
|
26
26
|
const updateHelpInfoState = (0, _react.useCallback)(state => {
|
|
27
27
|
setIsShowHelpInfo(state);
|
|
28
|
-
console.log("helpinfo:", state);
|
|
29
28
|
setIsShowArticleInfo(false);
|
|
30
29
|
}, []);
|
|
31
30
|
(0, _react.useEffect)(() => {
|
|
32
31
|
const eventBus = _eventBus.default.getInstance();
|
|
33
|
-
|
|
34
|
-
const unsubscribeArticleInfo = eventBus.subscribe(_eventTypes.EXTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, updateArticleInfoState);
|
|
32
|
+
const unsubscribeArticleInfo = eventBus.subscribe(_eventTypes.INTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE, updateArticleInfoState);
|
|
35
33
|
const unsubscribeHelpInfo = eventBus.subscribe(_eventTypes.EXTERNAL_EVENTS.ON_HELP_INFO_TOGGLE, updateHelpInfoState);
|
|
36
34
|
return () => {
|
|
37
35
|
unsubscribeHelpInfo();
|
|
38
36
|
unsubscribeArticleInfo();
|
|
39
37
|
};
|
|
40
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
}, [
|
|
39
|
+
}, []);
|
|
42
40
|
const containerClass = (0, _classnames.default)('sf-markdown-help-wrapper', {
|
|
43
41
|
'active': isShowArticleInfo || isShowHelpInfo
|
|
44
42
|
});
|
|
45
|
-
|
|
46
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
47
44
|
className: containerClass
|
|
48
45
|
}, isShowArticleInfo && /*#__PURE__*/_react.default.createElement(_articleInfo.default, {
|
|
49
46
|
children: children
|
|
50
|
-
}), isShowHelpInfo && /*#__PURE__*/_react.default.createElement(_hotkeysHelper.default, null))
|
|
47
|
+
}), isShowHelpInfo && /*#__PURE__*/_react.default.createElement(_hotkeysHelper.default, null));
|
|
51
48
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
.sf-markdown-help-wrapper {
|
|
2
2
|
display: none;
|
|
3
|
+
background-color: #fff;
|
|
3
4
|
border-left: 1px solid #eee;
|
|
4
|
-
flex:
|
|
5
|
+
flex: 0 0 300px;
|
|
5
6
|
height: 100%;
|
|
6
7
|
overflow-x: hidden;
|
|
7
8
|
overflow-y: auto;
|
|
9
|
+
width: 300px;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
.sf-markdown-help-wrapper.active {
|
|
11
13
|
display: flex;
|
|
12
14
|
flex-direction: column;
|
|
13
|
-
position: absolute;
|
|
14
|
-
right: 0;
|
|
15
15
|
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
min-height: 0;
|
|
6
6
|
min-width: 0;
|
|
7
|
-
position:relative;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
.sf-slate-editor-container .sf-slate-editor-toolbar {
|
|
@@ -30,15 +29,10 @@
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
.sf-slate-editor-container .sf-slate-scroll-container {
|
|
33
|
-
z-index: 100;
|
|
34
|
-
overflow-x: hidden;
|
|
35
|
-
overflow-y: auto;
|
|
36
32
|
height: 100%;
|
|
37
33
|
width: 100%;
|
|
38
34
|
background-color: #fafaf9;
|
|
39
35
|
overflow: auto;
|
|
40
|
-
min-width: 1200px;
|
|
41
|
-
flex: 1 1;
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
.sf-slate-editor-container .sf-slate-scroll-container.isWin::-webkit-scrollbar{
|
|
@@ -63,7 +57,6 @@
|
|
|
63
57
|
margin: 0 auto;
|
|
64
58
|
padding-top: 20px;
|
|
65
59
|
padding-bottom: 20px;
|
|
66
|
-
|
|
67
60
|
}
|
|
68
61
|
|
|
69
62
|
.sf-slate-editor-container .sf-slate-editor-content .article {
|
|
@@ -112,7 +105,6 @@
|
|
|
112
105
|
|
|
113
106
|
.sf-slate-article-container {
|
|
114
107
|
width: 100%;
|
|
115
|
-
/* margin-left: 280px; */
|
|
116
108
|
}
|
|
117
109
|
|
|
118
110
|
.sf-slate-article-container .article {
|
|
@@ -91,7 +91,12 @@ const Toolbar = _ref => {
|
|
|
91
91
|
isSupportInsertSeafileImage: isSupportInsertSeafileImage
|
|
92
92
|
})), isSupportFormula && /*#__PURE__*/_react.default.createElement(_menu10.default, commonProps), isSupportColumn && /*#__PURE__*/_react.default.createElement(_menu12.default, commonProps)), isShowSubTableMenu && /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, {
|
|
93
93
|
className: "sf-menu-group sf-table-operations-group"
|
|
94
|
-
}, /*#__PURE__*/_react.default.createElement(_tableOperator.AlignmentDropDown, commonProps), /*#__PURE__*/_react.default.createElement(_tableOperator.ColumnOperationDropDownList, commonProps), /*#__PURE__*/_react.default.createElement(_tableOperator.RowOperationDropDownList, commonProps), /*#__PURE__*/_react.default.createElement(_tableOperator.RemoveTableMenu, commonProps)), /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_menu11.default, commonProps)),
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_tableOperator.AlignmentDropDown, commonProps), /*#__PURE__*/_react.default.createElement(_tableOperator.ColumnOperationDropDownList, commonProps), /*#__PURE__*/_react.default.createElement(_tableOperator.RowOperationDropDownList, commonProps), /*#__PURE__*/_react.default.createElement(_tableOperator.RemoveTableMenu, commonProps)), /*#__PURE__*/_react.default.createElement(_commons.MenuGroup, null, /*#__PURE__*/_react.default.createElement(_menu11.default, commonProps)), isRichEditor && /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
+
className: "sf-slate-article-info-control",
|
|
96
|
+
onClick: updateArticleInfoState
|
|
97
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
98
|
+
className: sideIconClass
|
|
99
|
+
})), !isRichEditor && /*#__PURE__*/_react.default.createElement("div", {
|
|
95
100
|
className: "sf-slate-help-info-control",
|
|
96
101
|
onClick: onHelpIconToggle
|
|
97
102
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
package/package.json
CHANGED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
require("./style.css");
|
|
10
|
-
const ResizeWidth = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
minWidth,
|
|
13
|
-
maxWidth,
|
|
14
|
-
resizeWidth: resizeWidthAPI,
|
|
15
|
-
resizeWidthEnd
|
|
16
|
-
} = _ref;
|
|
17
|
-
const [isShowHandlerBar, setIsShowHandlerBar] = (0, _react.useState)(false);
|
|
18
|
-
const [drag, setDrag] = (0, _react.useState)(null);
|
|
19
|
-
const handlerRef = (0, _react.useRef)(null);
|
|
20
|
-
const handlerBarRef = (0, _react.useRef)(null);
|
|
21
|
-
const setHandlerBarTop = handlerTop => {
|
|
22
|
-
if (!handlerBarRef.current || handlerTop < 0) return;
|
|
23
|
-
handlerBarRef.current.style.top = handlerTop + 'px';
|
|
24
|
-
};
|
|
25
|
-
const setHandlerBarPosition = event => {
|
|
26
|
-
if (!handlerRef.current) return;
|
|
27
|
-
const {
|
|
28
|
-
top
|
|
29
|
-
} = handlerRef.current.getBoundingClientRect();
|
|
30
|
-
const handlerTop = event.pageY - top - 26 / 2;
|
|
31
|
-
setHandlerBarTop(handlerTop);
|
|
32
|
-
};
|
|
33
|
-
const getWidthFromMouseEvent = event => {
|
|
34
|
-
return event.pageX || event.touches && event.touches[0] && event.touches[0].pageX || event.changedTouches && event.changedTouches[event.changedTouches.length - 1].pageX;
|
|
35
|
-
};
|
|
36
|
-
const calculateResizedWidth = event => {
|
|
37
|
-
const width = getWidthFromMouseEvent(event);
|
|
38
|
-
const resizedWidth = document.body.clientWidth - width;
|
|
39
|
-
if (minWidth && resizedWidth < minWidth || maxWidth && resizedWidth > maxWidth) return -1;
|
|
40
|
-
return resizedWidth;
|
|
41
|
-
};
|
|
42
|
-
const onResizeWidth = event => {
|
|
43
|
-
const resizedWidth = calculateResizedWidth(event);
|
|
44
|
-
if (resizedWidth < 0) return;
|
|
45
|
-
if (resizeWidthAPI) {
|
|
46
|
-
resizeWidthAPI(resizedWidth);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const onDrag = event => {
|
|
50
|
-
onResizeWidth(event);
|
|
51
|
-
};
|
|
52
|
-
const onDragStart = (0, _react.useCallback)(event => {
|
|
53
|
-
if (event && event.dataTransfer && event.dataTransfer.setData) {
|
|
54
|
-
event.dataTransfer.setData('text/plain', 'dummy');
|
|
55
|
-
console.log(event.dataTransfer.getData('text/plain'));
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
}, []);
|
|
59
|
-
const onDragEnd = event => {
|
|
60
|
-
onResizeWidth(event);
|
|
61
|
-
};
|
|
62
|
-
const onMouseLeave = () => {
|
|
63
|
-
setIsShowHandlerBar(false);
|
|
64
|
-
};
|
|
65
|
-
const onMouseEnter = event => {
|
|
66
|
-
setIsShowHandlerBar(true);
|
|
67
|
-
setHandlerBarPosition(event);
|
|
68
|
-
if (handlerRef.current) {
|
|
69
|
-
handlerRef.current.addEventListener('mouseleave', onMouseLeave);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const onMouseOver = event => {
|
|
73
|
-
setHandlerBarPosition(event);
|
|
74
|
-
};
|
|
75
|
-
const onMouseDown = event => {
|
|
76
|
-
event.preventDefault && event.preventDefault();
|
|
77
|
-
const currDrag = onDragStart(event);
|
|
78
|
-
if (currDrag === null && event.button !== 0) return;
|
|
79
|
-
window.addEventListener('mouseup', onMouseUp);
|
|
80
|
-
window.addEventListener('mousemove', onMouseMove);
|
|
81
|
-
if (handlerRef.current) {
|
|
82
|
-
handlerRef.current.removeEventListener('mouseleave', onMouseLeave);
|
|
83
|
-
}
|
|
84
|
-
console.log(11111);
|
|
85
|
-
setDrag(currDrag);
|
|
86
|
-
};
|
|
87
|
-
const onMouseMove = event => {
|
|
88
|
-
event.preventDefault && event.preventDefault();
|
|
89
|
-
onDrag(event);
|
|
90
|
-
};
|
|
91
|
-
const onMouseUp = event => {
|
|
92
|
-
window.removeEventListener('mouseup', onMouseUp);
|
|
93
|
-
window.removeEventListener('mousemove', onMouseMove);
|
|
94
|
-
onDragEnd(event, drag);
|
|
95
|
-
setHandlerBarTop(-9999);
|
|
96
|
-
setDrag(null);
|
|
97
|
-
setIsShowHandlerBar(false);
|
|
98
|
-
if (resizeWidthEnd) {
|
|
99
|
-
const resizeWidth = calculateResizedWidth(event);
|
|
100
|
-
if (resizeWidth < 0) return;
|
|
101
|
-
resizeWidthEnd(resizeWidth);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
(0, _react.useEffect)(() => {
|
|
105
|
-
return () => {
|
|
106
|
-
window.removeEventListener('mouseup', onMouseUp);
|
|
107
|
-
window.removeEventListener('mousemove', onMouseMove);
|
|
108
|
-
};
|
|
109
|
-
// eslint-disable-next-line
|
|
110
|
-
}, []);
|
|
111
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
112
|
-
className: "sf-editor-resize-width-handler resize-handler-placement-right",
|
|
113
|
-
ref: handlerRef,
|
|
114
|
-
onMouseDown: onMouseDown,
|
|
115
|
-
onMouseOver: onMouseOver,
|
|
116
|
-
onMouseEnter: onMouseEnter,
|
|
117
|
-
onDrag: onDrag,
|
|
118
|
-
onDragStart: onDragStart,
|
|
119
|
-
onDragEnd: onDragEnd,
|
|
120
|
-
style: {
|
|
121
|
-
zIndex: 4
|
|
122
|
-
}
|
|
123
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
124
|
-
className: "sf-editor-resize-width-handler-content"
|
|
125
|
-
}, isShowHandlerBar && /*#__PURE__*/_react.default.createElement("div", {
|
|
126
|
-
className: "sf-editor-resize-width-handler-bar",
|
|
127
|
-
ref: handlerBarRef,
|
|
128
|
-
style: {
|
|
129
|
-
height: 26
|
|
130
|
-
}
|
|
131
|
-
})));
|
|
132
|
-
};
|
|
133
|
-
var _default = exports.default = ResizeWidth;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
.sf-editor-resize-width-handler {
|
|
2
|
-
height: 100%;
|
|
3
|
-
position: absolute;
|
|
4
|
-
right: 0;
|
|
5
|
-
top: 0;
|
|
6
|
-
width: 6px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.sf-editor-resize-width-handler.resize-handler-placement-right {
|
|
10
|
-
left: 0;
|
|
11
|
-
right: auto;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.sf-editor-resize-width-handler:hover {
|
|
15
|
-
cursor: col-resize;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.sf-editor-resize-width-handler .sf-editor-resize-width-handler-content {
|
|
19
|
-
background-color: initial;
|
|
20
|
-
height: 100%;
|
|
21
|
-
position: relative;
|
|
22
|
-
width: 2px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.sf-editor-resize-width-handler:hover .sf-editor-resize-width-handler-content {
|
|
26
|
-
background-color: #ccc;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.sf-editor-resize-width-handler .sf-editor-resize-width-handler-bar {
|
|
30
|
-
background-color: #2d7ff9;
|
|
31
|
-
border-radius: 3px;
|
|
32
|
-
content: "";
|
|
33
|
-
left: 50%;
|
|
34
|
-
margin-left: -3px;
|
|
35
|
-
position: absolute;
|
|
36
|
-
width: 6px;
|
|
37
|
-
}
|