@seafile/sdoc-editor 1.0.52 → 1.0.54
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/basic-sdk/assets/css/dropdown-menu.css +1 -0
- package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.css +4 -0
- package/dist/basic-sdk/extension/commons/dropdown-menu-item/index.js +7 -6
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +1 -0
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +2 -2
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.css +2 -2
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/column-list-menu.js +16 -12
- package/dist/basic-sdk/extension/plugins/seatable-column/menu/index.js +11 -7
- package/dist/basic-sdk/extension/plugins/seatable-tables/menu/index.js +9 -7
- package/dist/basic-sdk/extension/plugins/seatable-tables/menu/seatable-list.js +11 -11
- package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.css +4 -0
- package/dist/basic-sdk/extension/plugins/seatable-tables/op-menu/index.js +2 -6
- package/dist/basic-sdk/extension/plugins/seatable-tables/render-element/index.css +1 -1
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.css +2 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/insert-block-menu.js +1 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.css +0 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +1 -1
- package/dist/basic-sdk/extension/utils/index.js +22 -0
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useEffect, forwardRef } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import MenuShortcutPrompt from '../menu-shortcut-indicator';
|
|
5
5
|
import './index.css';
|
|
6
|
-
const DropdownMenuItem =
|
|
7
|
-
|
|
6
|
+
const DropdownMenuItem = forwardRef((props, ref) => {
|
|
7
|
+
const {
|
|
8
8
|
disabled,
|
|
9
9
|
onClick,
|
|
10
10
|
menuConfig,
|
|
11
11
|
children,
|
|
12
12
|
className,
|
|
13
13
|
shortcut
|
|
14
|
-
} =
|
|
14
|
+
} = props;
|
|
15
15
|
const {
|
|
16
16
|
t
|
|
17
17
|
} = useTranslation();
|
|
@@ -32,7 +32,8 @@ const DropdownMenuItem = _ref => {
|
|
|
32
32
|
'sdoc-link-dropdown-menu-item': shortcut
|
|
33
33
|
}),
|
|
34
34
|
id: menuConfig.id || '',
|
|
35
|
-
onClick: disabled ? () => {} : onClick || (() => {})
|
|
35
|
+
onClick: disabled ? () => {} : onClick || (() => {}),
|
|
36
|
+
ref: ref
|
|
36
37
|
}, /*#__PURE__*/React.createElement("div", {
|
|
37
38
|
className: "sdoc-dropdown-item-content"
|
|
38
39
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -42,5 +43,5 @@ const DropdownMenuItem = _ref => {
|
|
|
42
43
|
}), /*#__PURE__*/React.createElement("span", null, t(menuConfig.text))), shortcut && /*#__PURE__*/React.createElement(MenuShortcutPrompt, {
|
|
43
44
|
shortcuts: shortcut
|
|
44
45
|
})), isShowChildren && children);
|
|
45
|
-
};
|
|
46
|
+
});
|
|
46
47
|
export default DropdownMenuItem;
|
|
@@ -181,6 +181,7 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
181
181
|
}, /*#__PURE__*/React.createElement("div", {
|
|
182
182
|
className: "sdoc-search-langs"
|
|
183
183
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
184
|
+
autoFocus: true,
|
|
184
185
|
placeholder: t('Search_language'),
|
|
185
186
|
onChange: onChange
|
|
186
187
|
})), /*#__PURE__*/React.createElement(LangList, {
|
|
@@ -204,7 +204,7 @@ const Image = _ref => {
|
|
|
204
204
|
...style
|
|
205
205
|
},
|
|
206
206
|
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
|
|
207
|
-
contentEditable: "
|
|
207
|
+
contentEditable: "false",
|
|
208
208
|
suppressContentEditableWarning: true
|
|
209
209
|
}), /*#__PURE__*/React.createElement("img", {
|
|
210
210
|
ref: imageRef,
|
|
@@ -220,7 +220,7 @@ const Image = _ref => {
|
|
|
220
220
|
...style
|
|
221
221
|
},
|
|
222
222
|
onMouseOver: e => selectImageWhenSelectPartial(e, editor, element, isSelected),
|
|
223
|
-
contentEditable: "
|
|
223
|
+
contentEditable: "false",
|
|
224
224
|
suppressContentEditableWarning: true
|
|
225
225
|
}), /*#__PURE__*/React.createElement("span", {
|
|
226
226
|
className: "sdoc-image-inner"
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
|
|
16
16
|
.column-list-menu .column-list-menu-item-container {
|
|
17
17
|
padding: 3px 12px;
|
|
18
|
-
|
|
18
|
+
height: 32px;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.column-list-menu .column-list-menu-item-container .column-list-menu-item {
|
|
22
|
-
height:
|
|
22
|
+
height: 100%;
|
|
23
23
|
width: 100%;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
@@ -2,28 +2,31 @@ import React, { useMemo, useCallback, useRef, useEffect, useState } from 'react'
|
|
|
2
2
|
import { COLUMNS_ICON_CONFIG } from '../constants/column';
|
|
3
3
|
import { insertSeaTableColumn, getColumnType } from '../helpers';
|
|
4
4
|
import { COLUMN } from '../../../constants/element-type';
|
|
5
|
+
import { isOverflowPortByDirection } from '../../../utils';
|
|
5
6
|
import './column-list-menu.css';
|
|
6
7
|
const NOT_SUPPORT_COLUMN_TYPES = ['button', 'file'];
|
|
7
8
|
export default function ColumnListMenu(_ref) {
|
|
8
9
|
let {
|
|
9
10
|
editor,
|
|
10
|
-
insertPosition
|
|
11
|
+
insertPosition,
|
|
12
|
+
toggle
|
|
11
13
|
} = _ref;
|
|
12
14
|
const columnRef = useRef(null);
|
|
13
15
|
const [computedStyle, setComputedStyle] = useState({});
|
|
14
16
|
useEffect(() => {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
if (columnRef.current) {
|
|
18
|
+
// bottom overflow
|
|
19
|
+
if (isOverflowPortByDirection(columnRef.current, 'bottom')) {
|
|
20
|
+
return setComputedStyle({
|
|
21
|
+
bottom: '0px'
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// default
|
|
25
|
+
return setComputedStyle({
|
|
26
|
+
top: '-20px'
|
|
18
27
|
});
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
const centerPosition = parseInt(columnRef.current.getBoundingClientRect().height / 2);
|
|
22
|
-
setComputedStyle({
|
|
23
|
-
top: "-".concat(centerPosition, "px")
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}, [insertPosition]);
|
|
29
|
+
}, []);
|
|
27
30
|
const columns = useMemo(() => {
|
|
28
31
|
if (!editor.columns) return [];
|
|
29
32
|
return editor.columns.filter(column => !NOT_SUPPORT_COLUMN_TYPES.includes(column.type));
|
|
@@ -44,7 +47,8 @@ export default function ColumnListMenu(_ref) {
|
|
|
44
47
|
const onMousedown = useCallback(option => {
|
|
45
48
|
const active = isActive(editor);
|
|
46
49
|
insertSeaTableColumn(editor, active, option, insertPosition);
|
|
47
|
-
|
|
50
|
+
toggle && toggle();
|
|
51
|
+
}, [editor, insertPosition, toggle]);
|
|
48
52
|
return /*#__PURE__*/React.createElement("div", {
|
|
49
53
|
ref: columnRef,
|
|
50
54
|
className: "column-list-menu",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
2
|
import { MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../../../constants';
|
|
3
3
|
import DropdownMenuItem from '../../../commons/dropdown-menu-item';
|
|
4
4
|
import ColumnListMenu from './column-list-menu';
|
|
@@ -8,27 +8,31 @@ const SeaTableColumnMenu = _ref => {
|
|
|
8
8
|
let {
|
|
9
9
|
editor,
|
|
10
10
|
readonly,
|
|
11
|
-
insertPosition
|
|
11
|
+
insertPosition,
|
|
12
|
+
toggle
|
|
12
13
|
} = _ref;
|
|
14
|
+
const dropDownMenuRef = useRef(null);
|
|
13
15
|
const disabled = isMenuDisabled(editor, readonly);
|
|
14
16
|
const menuConfig = MENUS_CONFIG_MAP[ELEMENT_TYPE.COLUMN];
|
|
15
17
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
16
18
|
disabled: disabled,
|
|
17
19
|
menuConfig: menuConfig,
|
|
18
|
-
className: "pr-2"
|
|
20
|
+
className: "pr-2 sdoc-dropdown-menu-item-relative",
|
|
21
|
+
ref: dropDownMenuRef
|
|
19
22
|
}, !disabled && /*#__PURE__*/React.createElement("i", {
|
|
20
23
|
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
21
24
|
}), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
22
25
|
target: menuConfig.id,
|
|
23
|
-
trigger: "hover",
|
|
24
|
-
placement: "right-start",
|
|
25
26
|
hideArrow: true,
|
|
27
|
+
trigger: "hover",
|
|
26
28
|
fade: false,
|
|
27
|
-
popperClassName: "seatable-column-popover"
|
|
29
|
+
popperClassName: "seatable-column-popover",
|
|
30
|
+
container: dropDownMenuRef === null || dropDownMenuRef === void 0 ? void 0 : dropDownMenuRef.current
|
|
28
31
|
}, /*#__PURE__*/React.createElement(ColumnListMenu, {
|
|
29
32
|
editor: editor,
|
|
30
33
|
readonly: readonly,
|
|
31
|
-
insertPosition: insertPosition
|
|
34
|
+
insertPosition: insertPosition,
|
|
35
|
+
toggle: toggle
|
|
32
36
|
}))));
|
|
33
37
|
};
|
|
34
38
|
export default SeaTableColumnMenu;
|
|
@@ -9,28 +9,30 @@ const SeaTableTableMenu = _ref => {
|
|
|
9
9
|
let {
|
|
10
10
|
editor,
|
|
11
11
|
readonly,
|
|
12
|
-
insertPosition
|
|
12
|
+
insertPosition,
|
|
13
|
+
toggle
|
|
13
14
|
} = _ref;
|
|
14
|
-
const
|
|
15
|
+
const dropDownMenuRef = useRef(null);
|
|
15
16
|
const disabled = isInsertSeaTableTableDisabled(editor, readonly);
|
|
16
17
|
const menuConfig = MENUS_CONFIG_MAP[SEATABLE_TABLE];
|
|
17
18
|
const onViewClick = useCallback(item => {
|
|
18
19
|
insertSeaTableTable(editor, item, insertPosition);
|
|
19
|
-
|
|
20
|
+
toggle && toggle();
|
|
21
|
+
}, [editor, insertPosition, toggle]);
|
|
20
22
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
21
23
|
disabled: disabled,
|
|
22
24
|
menuConfig: menuConfig,
|
|
23
|
-
className: "pr-2"
|
|
25
|
+
className: "pr-2 sdoc-dropdown-menu-item-relative",
|
|
26
|
+
ref: dropDownMenuRef
|
|
24
27
|
}, !disabled && /*#__PURE__*/React.createElement("i", {
|
|
25
28
|
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
26
29
|
}), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
27
30
|
target: menuConfig.id,
|
|
28
31
|
trigger: "hover",
|
|
29
|
-
className: "sdoc-menu-popover sdoc-
|
|
30
|
-
placement: "right-start",
|
|
32
|
+
className: "sdoc-menu-popover sdoc-sub-dropdown-menu",
|
|
31
33
|
hideArrow: true,
|
|
32
34
|
fade: false,
|
|
33
|
-
|
|
35
|
+
container: dropDownMenuRef === null || dropDownMenuRef === void 0 ? void 0 : dropDownMenuRef.current
|
|
34
36
|
}, /*#__PURE__*/React.createElement(SeaTableList, {
|
|
35
37
|
editor: editor,
|
|
36
38
|
readonly: readonly,
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { isOverflowPortByDirection } from '../../../utils';
|
|
2
3
|
const SeaTableList = _ref => {
|
|
3
4
|
let {
|
|
4
5
|
editor,
|
|
5
|
-
insertPosition,
|
|
6
6
|
onViewClick
|
|
7
7
|
} = _ref;
|
|
8
8
|
const seatableRef = useRef(null);
|
|
9
9
|
const [computedStyle, setComputedStyle] = useState({});
|
|
10
10
|
const tables = editor.tables;
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
if (
|
|
12
|
+
if (seatableRef.current) {
|
|
13
|
+
// bottom overflow
|
|
14
|
+
if (isOverflowPortByDirection(seatableRef.current, 'bottom')) {
|
|
15
|
+
return setComputedStyle({
|
|
16
|
+
bottom: '0px'
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// default
|
|
13
20
|
setComputedStyle({
|
|
14
|
-
|
|
21
|
+
top: '-20px'
|
|
15
22
|
});
|
|
16
23
|
}
|
|
17
|
-
|
|
18
|
-
const centerPosition = parseInt(seatableRef.current.getBoundingClientRect().height / 2);
|
|
19
|
-
// 30 is seatable menu height
|
|
20
|
-
setComputedStyle({
|
|
21
|
-
top: "-".concat(centerPosition + 30, "px")
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}, [insertPosition]);
|
|
24
|
+
}, []);
|
|
25
25
|
return /*#__PURE__*/React.createElement("div", {
|
|
26
26
|
ref: seatableRef,
|
|
27
27
|
className: "sdoc-dropdown-menu-container sdoc-seatable-selected-table-list-wrapper",
|
|
@@ -54,6 +54,10 @@
|
|
|
54
54
|
justify-content: center;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
.sdoc-seatable-hover-menu-container .no-used-divider {
|
|
58
|
+
margin-right: 8px;
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
.sdoc-seatable-hover-menu-container .sdoc-seatable-hover-operation-item.sdoc-seatable-hover-operation-lang {
|
|
58
62
|
width: fit-content;
|
|
59
63
|
}
|
|
@@ -228,7 +228,7 @@ export default function OpMenu(_ref3) {
|
|
|
228
228
|
className: "sdoc-seatable-hover-operation-divider"
|
|
229
229
|
}), /*#__PURE__*/React.createElement("div", {
|
|
230
230
|
id: "sdoc_seatable_filter",
|
|
231
|
-
className: "sdoc-seatable-hover-operation-item"
|
|
231
|
+
className: "sdoc-seatable-hover-operation-item no-used-divider"
|
|
232
232
|
}, /*#__PURE__*/React.createElement("div", {
|
|
233
233
|
role: "button",
|
|
234
234
|
className: "op-item",
|
|
@@ -240,10 +240,8 @@ export default function OpMenu(_ref3) {
|
|
|
240
240
|
placement: "top",
|
|
241
241
|
fade: true
|
|
242
242
|
}, t('Filter'))), /*#__PURE__*/React.createElement("div", {
|
|
243
|
-
className: "sdoc-seatable-hover-operation-divider"
|
|
244
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
245
243
|
id: "sdoc_seatable_sort",
|
|
246
|
-
className: "sdoc-seatable-hover-operation-item"
|
|
244
|
+
className: "sdoc-seatable-hover-operation-item no-used-divider"
|
|
247
245
|
}, /*#__PURE__*/React.createElement("div", {
|
|
248
246
|
role: "button",
|
|
249
247
|
className: "op-item",
|
|
@@ -255,8 +253,6 @@ export default function OpMenu(_ref3) {
|
|
|
255
253
|
placement: "top",
|
|
256
254
|
fade: true
|
|
257
255
|
}, t('Sort'))), /*#__PURE__*/React.createElement("div", {
|
|
258
|
-
className: "sdoc-seatable-hover-operation-divider"
|
|
259
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
260
256
|
id: "sdoc_seatable_hidden_column",
|
|
261
257
|
className: "sdoc-seatable-hover-operation-item"
|
|
262
258
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -98,7 +98,7 @@ const SideMenu = (_ref, ref) => {
|
|
|
98
98
|
text: 'Insert_below',
|
|
99
99
|
iconClass: 'sdocfont sdoc-insert'
|
|
100
100
|
},
|
|
101
|
-
className: "pr-2"
|
|
101
|
+
className: "pr-2 sdoc-dropdown-menu-item-relative"
|
|
102
102
|
}, /*#__PURE__*/React.createElement("i", {
|
|
103
103
|
className: "sdocfont sdoc-right-slide sdoc-dropdown-item-right-icon"
|
|
104
104
|
}), /*#__PURE__*/React.createElement(InsertBelowMenu, {
|
|
@@ -9,4 +9,26 @@ export const isImage = url => {
|
|
|
9
9
|
};
|
|
10
10
|
export const isSameDomain = (currentUrl, targetUrl) => {
|
|
11
11
|
return String(currentUrl).split('/')[2] === String(targetUrl).split('/')[2];
|
|
12
|
+
};
|
|
13
|
+
export const isOverflowPortByDirection = (element, direction) => {
|
|
14
|
+
const viewWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
15
|
+
const viewHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
16
|
+
const {
|
|
17
|
+
top,
|
|
18
|
+
right,
|
|
19
|
+
bottom,
|
|
20
|
+
left
|
|
21
|
+
} = element.getBoundingClientRect();
|
|
22
|
+
if (direction === 'top') {
|
|
23
|
+
return top <= 0;
|
|
24
|
+
}
|
|
25
|
+
if (direction === 'bottom') {
|
|
26
|
+
return bottom >= viewHeight;
|
|
27
|
+
}
|
|
28
|
+
if (direction === 'left') {
|
|
29
|
+
return left <= 0;
|
|
30
|
+
}
|
|
31
|
+
if (direction === 'right') {
|
|
32
|
+
return right >= viewWidth;
|
|
33
|
+
}
|
|
12
34
|
};
|