@seafile/sdoc-editor 0.5.65 → 0.5.67
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/assets/css/plugin-editor.css +3 -0
- package/dist/basic-sdk/extension/commons/index.js +2 -1
- package/dist/basic-sdk/extension/commons/select/_option.js +32 -0
- package/dist/basic-sdk/extension/commons/select/field-setting.js +101 -0
- package/dist/basic-sdk/extension/commons/select/index.js +135 -0
- package/dist/basic-sdk/extension/commons/select/menu/index.js +4 -0
- package/dist/basic-sdk/extension/commons/select/menu/item.js +32 -0
- package/dist/basic-sdk/extension/commons/select/menu/menu.js +27 -0
- package/dist/basic-sdk/extension/commons/select/menu/style.css +43 -0
- package/dist/basic-sdk/extension/commons/select/style.css +149 -0
- package/dist/basic-sdk/extension/constants/element-type.js +1 -0
- package/dist/basic-sdk/extension/constants/menus-config.js +6 -1
- package/dist/basic-sdk/extension/plugins/column/constants/cell-types.js +29 -0
- package/dist/basic-sdk/extension/plugins/column/constants/column.js +28 -0
- package/dist/basic-sdk/extension/plugins/column/helpers.js +62 -0
- package/dist/basic-sdk/extension/plugins/column/index.js +12 -0
- package/dist/basic-sdk/extension/plugins/column/menu/index.js +28 -0
- package/dist/basic-sdk/extension/plugins/column/model.js +14 -0
- package/dist/basic-sdk/extension/plugins/column/plugin.js +24 -0
- package/dist/basic-sdk/extension/plugins/column/render-elem.js +111 -0
- package/dist/basic-sdk/extension/plugins/font/helpers.js +1 -0
- package/dist/basic-sdk/extension/plugins/index.js +2 -1
- package/dist/basic-sdk/extension/plugins/text-align/helpers.js +1 -0
- package/dist/basic-sdk/extension/render/custom-element.js +7 -1
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +7 -2
- package/dist/basic-sdk/extension/toolbar/insert-element-toolbar/index.js +19 -4
- package/dist/basic-sdk/extension/toolbar/side-toolbar/index.js +16 -1
- package/dist/basic-sdk/extension/toolbar/side-toolbar/side-menu.js +10 -3
- package/dist/basic-sdk/hooks/use-force-update.js +9 -0
- package/dist/index.js +3 -1
- package/dist/pages/document-plugin-editor.js +46 -0
- package/dist/pages/document-plugin-viewer.js +55 -0
- package/package.json +1 -1
- package/public/index.html +21 -22
- package/public/media/dtable-font.css +1566 -0
- package/public/media/dtable-fonts/dtable-font.eot +0 -0
- package/public/media/dtable-fonts/dtable-font.svg +793 -0
- package/public/media/dtable-fonts/dtable-font.ttf +0 -0
- package/public/media/dtable-fonts/dtable-font.woff +0 -0
- package/public/media/dtable-fonts/dtable-font.woff2 +0 -0
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +6 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +22 -8
|
@@ -2,4 +2,5 @@ import ColorMenu from './color-menu';
|
|
|
2
2
|
import ElementPopover from './element-popover';
|
|
3
3
|
import MoreDropdown from './more-dropdown';
|
|
4
4
|
import { MenuGroup, MenuItem } from './menu';
|
|
5
|
-
|
|
5
|
+
import Select from './select';
|
|
6
|
+
export { ColorMenu, ElementPopover, MenuGroup, MenuItem, MoreDropdown, Select };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
class Option extends React.Component {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
_defineProperty(this, "onClick", event => {
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
9
|
+
const {
|
|
10
|
+
option
|
|
11
|
+
} = this.props;
|
|
12
|
+
this.props.onOptionChanged(option);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
const {
|
|
17
|
+
option,
|
|
18
|
+
isActive,
|
|
19
|
+
optionClass
|
|
20
|
+
} = this.props;
|
|
21
|
+
const className = "option-item ".concat(optionClass || '', " ").concat(isActive ? 'active' : '');
|
|
22
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
23
|
+
className: className,
|
|
24
|
+
onClick: this.onClick
|
|
25
|
+
}, option.iconClass && /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
className: "item-icon ".concat(option.iconClass)
|
|
27
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
28
|
+
className: "label"
|
|
29
|
+
}, option.label));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default Option;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { withTranslation } from 'react-i18next';
|
|
5
|
+
import Menu from './menu';
|
|
6
|
+
class FieldSetting extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
_defineProperty(this, "onMouseEnter", () => {
|
|
10
|
+
if (!this.props.option) return;
|
|
11
|
+
const container = this.settingRef;
|
|
12
|
+
const {
|
|
13
|
+
height,
|
|
14
|
+
width
|
|
15
|
+
} = container.getBoundingClientRect();
|
|
16
|
+
const position = {
|
|
17
|
+
height,
|
|
18
|
+
width
|
|
19
|
+
};
|
|
20
|
+
this.setState({
|
|
21
|
+
isShowMenu: true,
|
|
22
|
+
position
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "onMouseLeave", () => {
|
|
26
|
+
this.setState({
|
|
27
|
+
isShowMenu: false
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
_defineProperty(this, "onBoldClick", event => {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
const {
|
|
33
|
+
option
|
|
34
|
+
} = this.props;
|
|
35
|
+
const newOption = _objectSpread(_objectSpread({}, option), {}, {
|
|
36
|
+
bold: !option.bold
|
|
37
|
+
});
|
|
38
|
+
this.props.onUpdateOption(newOption);
|
|
39
|
+
});
|
|
40
|
+
_defineProperty(this, "onItalicClick", event => {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
const {
|
|
43
|
+
option
|
|
44
|
+
} = this.props;
|
|
45
|
+
const newOption = _objectSpread(_objectSpread({}, option), {}, {
|
|
46
|
+
italic: !option.italic
|
|
47
|
+
});
|
|
48
|
+
this.props.onUpdateOption(newOption);
|
|
49
|
+
});
|
|
50
|
+
_defineProperty(this, "setSettingRef", ref => {
|
|
51
|
+
this.settingRef = ref;
|
|
52
|
+
});
|
|
53
|
+
this.state = {
|
|
54
|
+
isShowMenu: false,
|
|
55
|
+
position: {
|
|
56
|
+
top: 0,
|
|
57
|
+
left: 0
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
const {
|
|
63
|
+
option,
|
|
64
|
+
t
|
|
65
|
+
} = this.props;
|
|
66
|
+
const isDisable = !option;
|
|
67
|
+
const {
|
|
68
|
+
bold: isBold,
|
|
69
|
+
italic: isItalic
|
|
70
|
+
} = option || {};
|
|
71
|
+
const {
|
|
72
|
+
isShowMenu
|
|
73
|
+
} = this.state;
|
|
74
|
+
const className = "sdoc-field-setting ".concat(isDisable ? 'disable' : '', " option-item");
|
|
75
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
76
|
+
ref: this.setSettingRef,
|
|
77
|
+
className: className,
|
|
78
|
+
onMouseEnter: this.onMouseEnter,
|
|
79
|
+
onMouseLeave: this.onMouseLeave
|
|
80
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: "sdocfont sdoc-text-style"
|
|
82
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
83
|
+
className: "label"
|
|
84
|
+
}, t('Font_style')), /*#__PURE__*/React.createElement("span", {
|
|
85
|
+
className: "icon-container"
|
|
86
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
87
|
+
className: "sdocfont sdoc-caret-up op-icon"
|
|
88
|
+
})), isShowMenu && /*#__PURE__*/React.createElement(Menu, {
|
|
89
|
+
position: this.state.position
|
|
90
|
+
}, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
91
|
+
iconClass: 'sdocfont sdoc-bold',
|
|
92
|
+
isChecked: isBold,
|
|
93
|
+
onClick: this.onBoldClick
|
|
94
|
+
}, t('Bold')), /*#__PURE__*/React.createElement(Menu.Item, {
|
|
95
|
+
iconClass: 'sdocfont sdoc-italic',
|
|
96
|
+
isChecked: isItalic,
|
|
97
|
+
onClick: this.onItalicClick
|
|
98
|
+
}, t('Italic'))));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export default withTranslation('seafile-editor')(FieldSetting);
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Option from './_option';
|
|
4
|
+
import FieldSetting from './field-setting';
|
|
5
|
+
import './style.css';
|
|
6
|
+
class Select extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
_defineProperty(this, "handleSelector", event => {
|
|
10
|
+
if (this.selector && !this.selector.contains(event.target)) {
|
|
11
|
+
this.setState({
|
|
12
|
+
isShowSelector: false
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
_defineProperty(this, "getCurrentOption", () => {
|
|
17
|
+
const {
|
|
18
|
+
value,
|
|
19
|
+
options
|
|
20
|
+
} = this.props;
|
|
21
|
+
const currentOption = value && options.find(option => option.value === value.value);
|
|
22
|
+
return currentOption;
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(this, "onSelectToggle", event => {
|
|
25
|
+
const {
|
|
26
|
+
isShowSelector
|
|
27
|
+
} = this.state;
|
|
28
|
+
const newValue = !isShowSelector;
|
|
29
|
+
if (newValue) {
|
|
30
|
+
this.dropdownContainerHasInit = false;
|
|
31
|
+
}
|
|
32
|
+
this.setState({
|
|
33
|
+
isShowSelector: newValue
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(this, "onChange", option => {
|
|
37
|
+
this.setState({
|
|
38
|
+
isShowSelector: false,
|
|
39
|
+
currentOption: option
|
|
40
|
+
});
|
|
41
|
+
this.props.onChange(option);
|
|
42
|
+
});
|
|
43
|
+
_defineProperty(this, "onUpdateOption", option => {
|
|
44
|
+
this.setState({
|
|
45
|
+
currentOption: option
|
|
46
|
+
});
|
|
47
|
+
this.props.onChange(option);
|
|
48
|
+
});
|
|
49
|
+
_defineProperty(this, "setContainerRef", ref => {
|
|
50
|
+
this.dropdownContainer = ref;
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(this, "setSelectorRef", ref => {
|
|
53
|
+
this.selector = ref;
|
|
54
|
+
});
|
|
55
|
+
this.state = {
|
|
56
|
+
isShowSelector: false,
|
|
57
|
+
currentOption: this.getCurrentOption()
|
|
58
|
+
};
|
|
59
|
+
this.dropdownContainerHasInit = false;
|
|
60
|
+
}
|
|
61
|
+
componentDidMount() {
|
|
62
|
+
document.addEventListener('mousedown', this.handleSelector);
|
|
63
|
+
}
|
|
64
|
+
componentWillUnmount() {
|
|
65
|
+
document.removeEventListener('mousedown', this.handleSelector);
|
|
66
|
+
}
|
|
67
|
+
componentDidUpdate() {
|
|
68
|
+
const {
|
|
69
|
+
options
|
|
70
|
+
} = this.props;
|
|
71
|
+
const {
|
|
72
|
+
currentOption
|
|
73
|
+
} = this.state;
|
|
74
|
+
const activeIndex = currentOption && options.findIndex(option => option.value === currentOption.value);
|
|
75
|
+
if (activeIndex > -1) {
|
|
76
|
+
const scrollTop = 48 + (activeIndex + 1) * 32 - 150;
|
|
77
|
+
if (scrollTop < 0) return;
|
|
78
|
+
if (this.dropdownContainer && !this.dropdownContainerHasInit) {
|
|
79
|
+
this.dropdownContainerHasInit = true;
|
|
80
|
+
this.dropdownContainer.scrollTop = scrollTop;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
const {
|
|
86
|
+
selectClass,
|
|
87
|
+
optionClass,
|
|
88
|
+
isSelected,
|
|
89
|
+
options,
|
|
90
|
+
placeholder
|
|
91
|
+
} = this.props;
|
|
92
|
+
const {
|
|
93
|
+
currentOption,
|
|
94
|
+
isShowSelector
|
|
95
|
+
} = this.state;
|
|
96
|
+
const isActive = isShowSelector || isSelected;
|
|
97
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
98
|
+
ref: this.setSelectorRef,
|
|
99
|
+
className: "select-container ".concat(selectClass || '')
|
|
100
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
101
|
+
className: "control-container ".concat(isActive ? 'active' : ''),
|
|
102
|
+
onClick: this.onSelectToggle
|
|
103
|
+
}, !currentOption && /*#__PURE__*/React.createElement("span", {
|
|
104
|
+
className: "label placeholder"
|
|
105
|
+
}, placeholder), currentOption && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
106
|
+
className: "control-icon ".concat(currentOption.iconClass)
|
|
107
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
108
|
+
className: "control-label"
|
|
109
|
+
}, currentOption.label)), /*#__PURE__*/React.createElement("span", {
|
|
110
|
+
className: "operation"
|
|
111
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
112
|
+
className: "sdocfont sdoc-drop-down arrow"
|
|
113
|
+
}))), isShowSelector && /*#__PURE__*/React.createElement("span", {
|
|
114
|
+
className: "select-popover"
|
|
115
|
+
}, /*#__PURE__*/React.createElement(FieldSetting, {
|
|
116
|
+
option: currentOption,
|
|
117
|
+
onUpdateOption: this.onUpdateOption
|
|
118
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
119
|
+
className: "option-item-divider"
|
|
120
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
121
|
+
className: "option-item-wrapper",
|
|
122
|
+
ref: this.setContainerRef
|
|
123
|
+
}, options.map(option => {
|
|
124
|
+
const isActive = option.value === (currentOption && currentOption.value);
|
|
125
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
126
|
+
key: option.value,
|
|
127
|
+
optionClass: optionClass,
|
|
128
|
+
isActive: isActive,
|
|
129
|
+
option: option,
|
|
130
|
+
onOptionChanged: this.onChange
|
|
131
|
+
});
|
|
132
|
+
}))));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export default Select;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './style.css';
|
|
4
|
+
class MenuItem extends React.Component {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
_defineProperty(this, "onClick", e => {
|
|
8
|
+
this.props.onClick(e);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
render() {
|
|
12
|
+
const {
|
|
13
|
+
children,
|
|
14
|
+
itemClass,
|
|
15
|
+
iconClass,
|
|
16
|
+
isChecked
|
|
17
|
+
} = this.props;
|
|
18
|
+
const containerClass = "sdoc-menu-item ".concat(itemClass || '');
|
|
19
|
+
const itemIconClass = "menu-item-icon ".concat(iconClass || '');
|
|
20
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
21
|
+
className: containerClass,
|
|
22
|
+
onClick: this.onClick
|
|
23
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
24
|
+
className: itemIconClass
|
|
25
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
className: "menu-item-name"
|
|
27
|
+
}, children), isChecked && /*#__PURE__*/React.createElement("span", {
|
|
28
|
+
className: "sdocfont sdoc-check-mark"
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default MenuItem;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
class Menu extends React.Component {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
_defineProperty(this, "getStyle", () => {
|
|
7
|
+
const {
|
|
8
|
+
position
|
|
9
|
+
} = this.props;
|
|
10
|
+
const {
|
|
11
|
+
width
|
|
12
|
+
} = position;
|
|
13
|
+
return {
|
|
14
|
+
marginLeft: width - 10,
|
|
15
|
+
marginTop: '30px'
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
const style = this.getStyle();
|
|
21
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
22
|
+
className: "sdoc-menu-container",
|
|
23
|
+
style: style
|
|
24
|
+
}, this.props.children);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default Menu;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.sdoc-menu-container {
|
|
2
|
+
position: absolute;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
width: 150px;
|
|
6
|
+
padding: 8px 0;
|
|
7
|
+
min-width: 80px;
|
|
8
|
+
overflow-y: auto;
|
|
9
|
+
overflow-x: hidden;
|
|
10
|
+
border: 1px solid #e5e5e5;
|
|
11
|
+
box-shadow: 0 4px 10px #eee;
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
background: #fff;
|
|
14
|
+
color: #212529;
|
|
15
|
+
z-index: 1080;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.sdoc-menu-container .sdoc-menu-item {
|
|
19
|
+
height: 32px;
|
|
20
|
+
line-height: 32px;
|
|
21
|
+
display: flex;
|
|
22
|
+
padding: 0 10px;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
position: relative;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sdoc-menu-container .sdoc-menu-item:hover {
|
|
28
|
+
background-color: #f5f5f5;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sdoc-menu-container .sdoc-menu-item .menu-item-icon {
|
|
32
|
+
margin-right: 5px;
|
|
33
|
+
color: #aaa;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.sdoc-menu-container .sdoc-menu-item .sdoc-check-mark {
|
|
37
|
+
position: absolute;
|
|
38
|
+
right: 10px;
|
|
39
|
+
height: 32px;
|
|
40
|
+
line-height: 32px;
|
|
41
|
+
font-size: 13px;
|
|
42
|
+
color: #aaa;
|
|
43
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
.select-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
margin: 0 5px;
|
|
5
|
+
font-weight: normal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.select-container .control-container {
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
border: 1px solid #ccc;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
padding: 0 10px;
|
|
15
|
+
height: 24px;
|
|
16
|
+
font-size: 13px;
|
|
17
|
+
line-height: 1.5;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
user-select: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.select-container .control-container.active,
|
|
23
|
+
.select-container .control-container:hover {
|
|
24
|
+
border: 1px solid #3C88FD;
|
|
25
|
+
box-shadow: 0 0 0 2px rgb(70 127 207 / 25%);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.select-container .control-container .placeholder {
|
|
29
|
+
color: #BFBFBF;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.select-container .control-container .control-icon {
|
|
33
|
+
font-size: 13px;
|
|
34
|
+
color: rgb(170, 170, 170);
|
|
35
|
+
cursor: default;
|
|
36
|
+
margin-right: 5px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.select-container .control-container .operation {
|
|
40
|
+
margin-left: 8px;
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.select-container .control-container .arrow {
|
|
47
|
+
color: #949494;
|
|
48
|
+
display: inline-block;
|
|
49
|
+
font-size: 12px;
|
|
50
|
+
transform: scale(.8);
|
|
51
|
+
transition: all .1s;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.select-container .control-container .arrow:hover {
|
|
55
|
+
color: #666;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.select-container .select-popover {
|
|
59
|
+
position: absolute;
|
|
60
|
+
left: 0;
|
|
61
|
+
display: flex;
|
|
62
|
+
min-width: 80px;
|
|
63
|
+
max-height: 265px;
|
|
64
|
+
margin-top: 4px;
|
|
65
|
+
padding: 8px 0;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
border: 1px solid #e5e5e5;
|
|
68
|
+
box-shadow: 0 4px 10px #eee;
|
|
69
|
+
border-radius: 4px;
|
|
70
|
+
background: #fff;
|
|
71
|
+
z-index: 10;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.select-popover .option-item-divider {
|
|
75
|
+
margin-top: 8px;
|
|
76
|
+
border-top: 1px solid #EFEFEF;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.select-popover .sdoc-field-setting {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
position: relative;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.select-popover .sdoc-field-setting .icon-container {
|
|
86
|
+
position: absolute;
|
|
87
|
+
right: 10px;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.select-popover .sdoc-field-setting .sdoc-text-style {
|
|
94
|
+
font-size: 14px;
|
|
95
|
+
color: #aaa;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.select-popover .sdoc-field-setting .op-icon {
|
|
99
|
+
font-size: 12px;
|
|
100
|
+
transform: rotate(90deg);
|
|
101
|
+
color: #aaa;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.select-popover .option-item-wrapper {
|
|
105
|
+
flex: 1;
|
|
106
|
+
min-height: 0;
|
|
107
|
+
min-width: 0;
|
|
108
|
+
overflow: auto;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.select-popover .option-item {
|
|
112
|
+
flex-shrink: 0;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
min-width: 80px;
|
|
116
|
+
height: 32px;
|
|
117
|
+
padding: 0 12px;
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
overflow-wrap: normal;
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.select-popover .option-item:hover {
|
|
124
|
+
background-color: #F5F5F5;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.select-popover .option-item.active {
|
|
128
|
+
background-color: #39A0FF;
|
|
129
|
+
color: #fff;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.select-popover .option-item.disable {
|
|
133
|
+
color: #aaa;
|
|
134
|
+
cursor: default;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.select-popover .option-item .item-icon {
|
|
138
|
+
font-size: 14px;
|
|
139
|
+
color: rgb(170, 170, 170);
|
|
140
|
+
cursor: default;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.select-popover .option-item.active .item-icon {
|
|
144
|
+
color: #fff;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.select-popover .option-item .label {
|
|
148
|
+
margin: 0 5px;
|
|
149
|
+
}
|
|
@@ -28,6 +28,7 @@ export const MENTION = 'mention';
|
|
|
28
28
|
export const MENTION_TEMP = 'mention_temp';
|
|
29
29
|
export const FILE_LINK_INSET_INPUT_TEMP = 'file_link_insert_input_temp';
|
|
30
30
|
export const QUICK_INSERT = 'quick_insert';
|
|
31
|
+
export const COLUMN = 'column';
|
|
31
32
|
|
|
32
33
|
// font
|
|
33
34
|
export const FONT_SIZE = 'font-size';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RECENT_USED_HIGHLIGHT_COLORS_KEY, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, RECENT_USED_FONT_COLORS_KEY, DEFAULT_FONT_COLOR, DEFAULT_LAST_USED_FONT_COLOR } from './color';
|
|
2
|
-
import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, CODE_BLOCK, LINK, IMAGE, TABLE, SDOC_LINK, FILE_LINK, PARAGRAPH, CALL_OUT } from './element-type';
|
|
2
|
+
import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, CODE_BLOCK, LINK, IMAGE, TABLE, SDOC_LINK, FILE_LINK, PARAGRAPH, CALL_OUT, COLUMN } from './element-type';
|
|
3
3
|
export const UNDO = 'undo';
|
|
4
4
|
export const REDO = 'redo';
|
|
5
5
|
export const CLEAR_FORMAT = 'clear_format';
|
|
@@ -191,6 +191,11 @@ export const MENUS_CONFIG_MAP = {
|
|
|
191
191
|
id: "sdoc_".concat(SEARCH_REPLACE),
|
|
192
192
|
iconClass: 'sdocfont sdoc-find-replace',
|
|
193
193
|
text: 'Search_and_replace'
|
|
194
|
+
},
|
|
195
|
+
[COLUMN]: {
|
|
196
|
+
id: "sdoc".concat(COLUMN),
|
|
197
|
+
iconClass: 'sdocfont sdoc-choose-column',
|
|
198
|
+
text: 'Insert_column'
|
|
194
199
|
}
|
|
195
200
|
};
|
|
196
201
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const DEFAULT = 'default';
|
|
2
|
+
export const NUMBER = 'number';
|
|
3
|
+
export const TEXT = 'text';
|
|
4
|
+
export const CHECKBOX = 'checkbox';
|
|
5
|
+
export const DATE = 'date';
|
|
6
|
+
export const SINGLE_SELECT = 'single-select';
|
|
7
|
+
export const LONG_TEXT = 'long-text';
|
|
8
|
+
export const IMAGE = 'image';
|
|
9
|
+
export const FILE = 'file';
|
|
10
|
+
export const MULTIPLE_SELECT = 'multiple-select';
|
|
11
|
+
export const COLLABORATOR = 'collaborator';
|
|
12
|
+
export const LINK = 'link';
|
|
13
|
+
export const FORMULA = 'formula';
|
|
14
|
+
export const LINK_FORMULA = 'link-formula';
|
|
15
|
+
export const CREATOR = 'creator';
|
|
16
|
+
export const CTIME = 'ctime';
|
|
17
|
+
export const LAST_MODIFIER = 'last-modifier';
|
|
18
|
+
export const MTIME = 'mtime';
|
|
19
|
+
export const GEOLOCATION = 'geolocation';
|
|
20
|
+
export const AUTO_NUMBER = 'auto-number';
|
|
21
|
+
export const URL = 'url';
|
|
22
|
+
export const EMAIL = 'email';
|
|
23
|
+
export const DURATION = 'duration';
|
|
24
|
+
export const BUTTON = 'button';
|
|
25
|
+
export const RATE = 'rate';
|
|
26
|
+
|
|
27
|
+
// formula | link-formula column calculate result type
|
|
28
|
+
export const BOOL = 'bool';
|
|
29
|
+
export const STRING = 'string';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as CellType from './cell-types';
|
|
2
|
+
export const COLUMNS_ICON_CONFIG = {
|
|
3
|
+
[CellType.DEFAULT]: 'dtable-font dtable-icon-single-line-text',
|
|
4
|
+
[CellType.TEXT]: 'dtable-font dtable-icon-single-line-text',
|
|
5
|
+
[CellType.NUMBER]: 'dtable-font dtable-icon-number',
|
|
6
|
+
[CellType.CHECKBOX]: 'dtable-font dtable-icon-check-square-solid',
|
|
7
|
+
[CellType.DATE]: 'dtable-font dtable-icon-calendar-alt-solid',
|
|
8
|
+
[CellType.SINGLE_SELECT]: 'dtable-font dtable-icon-single-election',
|
|
9
|
+
[CellType.LONG_TEXT]: 'dtable-font dtable-icon-long-text',
|
|
10
|
+
[CellType.IMAGE]: 'dtable-font dtable-icon-picture',
|
|
11
|
+
[CellType.FILE]: 'dtable-font dtable-icon-file-alt-solid',
|
|
12
|
+
[CellType.MULTIPLE_SELECT]: 'dtable-font dtable-icon-multiple-selection',
|
|
13
|
+
[CellType.COLLABORATOR]: 'dtable-font dtable-icon-collaborator',
|
|
14
|
+
[CellType.LINK]: 'dtable-font dtable-icon-link-other-record',
|
|
15
|
+
[CellType.FORMULA]: 'dtable-font dtable-icon-formula',
|
|
16
|
+
[CellType.LINK_FORMULA]: 'dtable-font dtable-icon-link-formulas',
|
|
17
|
+
[CellType.CREATOR]: 'dtable-font dtable-icon-creator',
|
|
18
|
+
[CellType.CTIME]: 'dtable-font dtable-icon-creation-time',
|
|
19
|
+
[CellType.LAST_MODIFIER]: 'dtable-font dtable-icon-creator',
|
|
20
|
+
[CellType.MTIME]: 'dtable-font dtable-icon-creation-time',
|
|
21
|
+
[CellType.GEOLOCATION]: 'dtable-font dtable-icon-location',
|
|
22
|
+
[CellType.AUTO_NUMBER]: 'dtable-font dtable-icon-autonumber',
|
|
23
|
+
[CellType.URL]: 'dtable-font dtable-icon-url',
|
|
24
|
+
[CellType.EMAIL]: 'dtable-font dtable-icon-email',
|
|
25
|
+
[CellType.DURATION]: 'dtable-font dtable-icon-duration',
|
|
26
|
+
[CellType.BUTTON]: 'dtable-font dtable-icon-button',
|
|
27
|
+
[CellType.RATE]: 'dtable-font dtable-icon-rate'
|
|
28
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { Editor, Transforms } from '@seafile/slate';
|
|
3
|
+
import slugid from 'slugid';
|
|
4
|
+
import { BLOCKQUOTE, CHECK_LIST_ITEM, COLUMN, IMAGE, ORDERED_LIST, PARAGRAPH, TABLE_CELL, UNORDERED_LIST } from '../../constants/element-type';
|
|
5
|
+
import { focusEditor, getNodeType } from '../../core';
|
|
6
|
+
import Column from './model';
|
|
7
|
+
export const isMenuDisabled = (editor, readonly) => {
|
|
8
|
+
if (readonly) return true;
|
|
9
|
+
if (editor.selection == null) return true;
|
|
10
|
+
const [nodeEntry] = Editor.nodes(editor, {
|
|
11
|
+
match: n => {
|
|
12
|
+
const type = getNodeType(n);
|
|
13
|
+
|
|
14
|
+
// Only available for p and blockquote
|
|
15
|
+
if (type === PARAGRAPH) return true;
|
|
16
|
+
if (type === BLOCKQUOTE) return true;
|
|
17
|
+
if (type === UNORDERED_LIST) return true;
|
|
18
|
+
if (type === ORDERED_LIST) return true;
|
|
19
|
+
if (type === CHECK_LIST_ITEM) return true;
|
|
20
|
+
if (type === IMAGE) return true;
|
|
21
|
+
if (type === TABLE_CELL) return true;
|
|
22
|
+
return false;
|
|
23
|
+
},
|
|
24
|
+
universal: true,
|
|
25
|
+
mode: 'highest' // Match top level
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Match to p blockquote, do not disable
|
|
29
|
+
if (nodeEntry) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
export const getColumnType = editor => {
|
|
35
|
+
const [match] = Editor.nodes(editor, {
|
|
36
|
+
match: n => getNodeType(n) === COLUMN,
|
|
37
|
+
universal: true
|
|
38
|
+
});
|
|
39
|
+
if (!match) return PARAGRAPH;
|
|
40
|
+
const [n] = match;
|
|
41
|
+
return getNodeType(n);
|
|
42
|
+
};
|
|
43
|
+
export const insertSeaTableColumn = (editor, active) => {
|
|
44
|
+
if (!active) {
|
|
45
|
+
const column = new Column({});
|
|
46
|
+
column.id = slugid.nice();
|
|
47
|
+
Transforms.insertNodes(editor, _objectSpread({}, column));
|
|
48
|
+
}
|
|
49
|
+
focusEditor(editor);
|
|
50
|
+
};
|
|
51
|
+
export const setSeaTableColumn = (editor, data) => {
|
|
52
|
+
Transforms.setNodes(editor, {
|
|
53
|
+
data: data
|
|
54
|
+
}, {
|
|
55
|
+
match: node => node.type === COLUMN,
|
|
56
|
+
at: editor.selection
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export const getColumnByKey = (columns, key) => {
|
|
60
|
+
const column = columns.find(item => item.key === key);
|
|
61
|
+
return column || null;
|
|
62
|
+
};
|