@seafile/sdoc-editor 0.1.88 → 0.1.90
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 +6 -0
- package/dist/basic-sdk/assets/css/layout.css +3 -1
- package/dist/basic-sdk/editor.js +2 -2
- package/dist/basic-sdk/extension/{menu → commons}/color-menu/color-item.js +2 -2
- package/dist/basic-sdk/extension/{menu → commons}/color-menu/index.css +47 -19
- package/dist/basic-sdk/extension/{menu → commons}/color-menu/index.js +38 -27
- package/dist/basic-sdk/extension/commons/{modal-portal → element-popover}/index.js +11 -8
- package/dist/basic-sdk/extension/commons/index.js +5 -0
- package/dist/basic-sdk/extension/commons/menu/menu.css +85 -0
- package/dist/basic-sdk/extension/commons/more-dropdown/index.js +38 -0
- package/dist/basic-sdk/extension/constants/index.js +5 -2
- package/dist/basic-sdk/extension/index.js +2 -2
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/check-list/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/clear-format/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +3 -3
- package/dist/basic-sdk/extension/plugins/code-block/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/link/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/link/render-elem.js +2 -1
- package/dist/basic-sdk/extension/plugins/list/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/dialog/custom-table-size-dialog/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/helpers.js +1 -2
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +9 -5
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.css +16 -7
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +7 -6
- package/dist/basic-sdk/extension/plugins/table/menu/table-context-menu/index.js +3 -3
- package/dist/basic-sdk/extension/plugins/table/menu/table-menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/plugin.js +1 -2
- package/dist/basic-sdk/extension/plugins/table/render/render-cell.js +2 -2
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +81 -110
- package/dist/basic-sdk/extension/plugins/text-style/menu/index.js +6 -5
- package/dist/basic-sdk/extension/toolbar/context-toolbar/index.css +10 -0
- package/dist/basic-sdk/extension/toolbar/context-toolbar/index.js +56 -0
- package/dist/basic-sdk/extension/toolbar/header-toolbar/index.js +54 -0
- package/dist/basic-sdk/extension/toolbar/{redo-undo.js → header-toolbar/redo-undo.js} +2 -2
- package/dist/basic-sdk/extension/toolbar/index.js +3 -54
- package/dist/basic-sdk/hooks/use-selection-position.js +11 -3
- package/dist/basic-sdk/node-id/index.js +1 -1
- package/dist/layout/layout.css +3 -0
- package/dist/utils/local-storage-utils.js +16 -2
- package/package.json +1 -1
- package/dist/basic-sdk/constants/index.js +0 -1
- package/dist/basic-sdk/extension/menu/menu.css +0 -34
- package/dist/basic-sdk/extension/plugins/text-align/menu/style.css +0 -53
- package/dist/components/more-dropdown/index.js +0 -75
- package/dist/components/more-dropdown/style.css +0 -64
- /package/dist/basic-sdk/extension/{menu → commons/menu}/index.js +0 -0
- /package/dist/basic-sdk/extension/{menu → commons/menu}/menu-group.js +0 -0
- /package/dist/basic-sdk/extension/{menu → commons/menu}/menu-item.js +0 -0
- /package/dist/basic-sdk/extension/plugins/table/{number-input.js → dialog/custom-table-size-dialog/number-input.js} +0 -0
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
width: 100%;
|
|
17
17
|
padding: 4px 24px;
|
|
18
18
|
user-select: none;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
.sdoc-dropdown-menu .sdoc-dropdown-menu-item:hover {
|
|
22
24
|
background-color: rgb(245, 245, 245);
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
.sdoc-dropdown-menu .sdoc-dropdown-menu-item .sdocfont {
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
background-color: #fff;
|
|
15
15
|
user-select: none;
|
|
16
16
|
border-bottom: 1px solid #e5e6e8;
|
|
17
|
+
position: relative;
|
|
18
|
+
z-index: 102;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
.sdoc-editor-container .sdoc-editor-content {
|
|
@@ -59,7 +61,7 @@
|
|
|
59
61
|
|
|
60
62
|
.sdoc-editor-container .sdoc-editor-content .article {
|
|
61
63
|
width: 794px;
|
|
62
|
-
min-height:
|
|
64
|
+
min-height: 800px;
|
|
63
65
|
padding: 40px 60px;
|
|
64
66
|
background-color: #fff;
|
|
65
67
|
border: 1px solid #e5e6e8;
|
package/dist/basic-sdk/editor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Editable, ReactEditor, Slate } from '@seafile/slate-react';
|
|
4
|
-
import defaultEditor, { renderLeaf, renderElement, Toolbar } from './extension';
|
|
4
|
+
import defaultEditor, { renderLeaf, renderElement, Toolbar, ContextToolbar } from './extension';
|
|
5
5
|
import { focusEditor, getAboveBlockNode, getNextNode, getPrevNode, isSelectionAtBlockEnd, isSelectionAtBlockStart } from './extension/core';
|
|
6
6
|
import { withSocketIO } from './socket';
|
|
7
7
|
import withNodeId from './node-id';
|
|
@@ -232,7 +232,7 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
232
232
|
editor: editor,
|
|
233
233
|
value: slateValue,
|
|
234
234
|
onChange: onChange
|
|
235
|
-
}, /*#__PURE__*/React.createElement(CommentContextProvider, null, /*#__PURE__*/React.createElement("div", {
|
|
235
|
+
}, /*#__PURE__*/React.createElement(ContextToolbar, null), /*#__PURE__*/React.createElement(CommentContextProvider, null, /*#__PURE__*/React.createElement("div", {
|
|
236
236
|
className: "article",
|
|
237
237
|
ref: articleRef
|
|
238
238
|
}, /*#__PURE__*/React.createElement(SetNodeToDecorations, null), /*#__PURE__*/React.createElement(Editable, {
|
|
@@ -4,10 +4,10 @@ import classnames from 'classnames';
|
|
|
4
4
|
var ColorItem = function ColorItem(_ref) {
|
|
5
5
|
var t = _ref.t,
|
|
6
6
|
color = _ref.color,
|
|
7
|
-
|
|
7
|
+
lastUsedColor = _ref.lastUsedColor;
|
|
8
8
|
return /*#__PURE__*/React.createElement("div", {
|
|
9
9
|
className: classnames('sdoc-color-item', {
|
|
10
|
-
'selected':
|
|
10
|
+
'selected': lastUsedColor === color.value
|
|
11
11
|
}),
|
|
12
12
|
style: {
|
|
13
13
|
backgroundColor: color.value
|
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
.menu-group .sdoc-color-menu {
|
|
2
|
-
|
|
1
|
+
.menu-group .sdoc-color-menu.menu-show {
|
|
2
|
+
background: #e5e5e5;
|
|
3
|
+
border-radius: 2px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.menu-group .sdoc-color-menu .last-used-color-container {
|
|
7
|
+
height: 100%;
|
|
3
8
|
display: flex;
|
|
4
|
-
|
|
9
|
+
flex-direction: column;
|
|
5
10
|
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
6
12
|
}
|
|
7
13
|
|
|
8
|
-
.menu-group .sdoc-color-menu.disabled {
|
|
9
|
-
|
|
14
|
+
.menu-group .sdoc-color-menu .last-used-color-container.disabled {
|
|
15
|
+
padding-right: 0;
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
.menu-group .sdoc-color-menu
|
|
13
|
-
|
|
18
|
+
.menu-group .sdoc-color-menu .sdoc-color-toggle {
|
|
19
|
+
height: 100%;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.menu-group .sdoc-color-menu .sdoc-color-toggle:hover,
|
|
26
|
+
.menu-group .sdoc-color-menu .last-used-color-container:not(.disabled):hover {
|
|
27
|
+
background-color: rgba(0, 0, 0, 0.08);
|
|
14
28
|
}
|
|
15
29
|
|
|
16
|
-
.sdoc-color-menu .sdoc-color-toggle
|
|
17
|
-
|
|
18
|
-
transform: scale(.8);
|
|
30
|
+
.menu-group .sdoc-color-menu.disabled .sdoc-color-toggle {
|
|
31
|
+
display: none;
|
|
19
32
|
}
|
|
20
33
|
|
|
21
34
|
.sdoc-color-menu .sdoc-color-icon {
|
|
22
35
|
font-size: 12px !important;
|
|
23
36
|
height: 12px;
|
|
37
|
+
width: 12px;
|
|
24
38
|
line-height: 12px;
|
|
25
39
|
}
|
|
26
40
|
|
|
27
|
-
.sdoc-color-menu .
|
|
28
|
-
width:
|
|
41
|
+
.sdoc-color-menu .last-used-color {
|
|
42
|
+
width: 14px;
|
|
29
43
|
height: 3px;
|
|
30
44
|
border-radius: 1px;
|
|
31
45
|
margin-top: 2px;
|
|
@@ -33,7 +47,7 @@
|
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
.sdoc-color-menu-popover .popover {
|
|
36
|
-
left: -
|
|
50
|
+
left: -30px !important;
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
.sdoc-color-menu-popover .sdoc-color-dropdown-menu {
|
|
@@ -64,6 +78,7 @@
|
|
|
64
78
|
}
|
|
65
79
|
|
|
66
80
|
.sdoc-color-menu-popover .sdoc-color-item {
|
|
81
|
+
position: relative;
|
|
67
82
|
height: 20px;
|
|
68
83
|
width: 20px;
|
|
69
84
|
margin-right: 3px;
|
|
@@ -71,17 +86,24 @@
|
|
|
71
86
|
border: 0.5px solid rgba(0, 0, 0, .08);
|
|
72
87
|
}
|
|
73
88
|
|
|
74
|
-
.sdoc-color-menu-popover .sdoc-color-item.selected {
|
|
75
|
-
|
|
89
|
+
.sdoc-color-menu-popover .sdoc-color-item:not(.selected):hover::before {
|
|
90
|
+
content: '';
|
|
91
|
+
position: absolute;
|
|
92
|
+
width: calc(100% + 5px);
|
|
93
|
+
height: calc((100% + 5px));
|
|
94
|
+
top: -2.5px;
|
|
95
|
+
left: -2.5px;
|
|
96
|
+
pointer-events: none;
|
|
97
|
+
border: 1px solid rgba(0, 0, 0, .24);
|
|
76
98
|
}
|
|
77
99
|
|
|
78
100
|
.sdoc-color-menu-popover .sdoc-color-item.selected::after {
|
|
79
101
|
content: '';
|
|
80
102
|
position: absolute;
|
|
81
|
-
width: calc(100% +
|
|
82
|
-
height: calc((100% +
|
|
83
|
-
top: -
|
|
84
|
-
left: -
|
|
103
|
+
width: calc(100% + 5px);
|
|
104
|
+
height: calc((100% + 5px));
|
|
105
|
+
top: -2.5px;
|
|
106
|
+
left: -2.5px;
|
|
85
107
|
pointer-events: none;
|
|
86
108
|
border: 1px solid rgba(0, 0, 0, .88);
|
|
87
109
|
}
|
|
@@ -131,3 +153,9 @@
|
|
|
131
153
|
.sdoc-more-colors-popover .popover {
|
|
132
154
|
left: 10px !important;
|
|
133
155
|
}
|
|
156
|
+
|
|
157
|
+
/* commission */
|
|
158
|
+
.menu-group #button-sdoc-highlight-color .sdoc-color-icon {
|
|
159
|
+
position: relative;
|
|
160
|
+
left: 1px;
|
|
161
|
+
}
|
|
@@ -4,7 +4,7 @@ import { withTranslation } from 'react-i18next';
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { UncontrolledPopover, UncontrolledTooltip } from 'reactstrap';
|
|
6
6
|
import { ChromePicker } from 'react-color';
|
|
7
|
-
import { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_COLORS
|
|
7
|
+
import { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_COLORS } from '../../constants';
|
|
8
8
|
import { LocalStorage } from '../../../../utils';
|
|
9
9
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
10
10
|
import ColorItem from './color-item';
|
|
@@ -14,44 +14,52 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
14
14
|
id = _ref.id,
|
|
15
15
|
isRichEditor = _ref.isRichEditor,
|
|
16
16
|
className = _ref.className,
|
|
17
|
+
popoverClassName = _ref.popoverClassName,
|
|
17
18
|
disabled = _ref.disabled,
|
|
18
19
|
t = _ref.t,
|
|
19
20
|
setColor = _ref.setColor,
|
|
20
|
-
|
|
21
|
+
recentUsedColorsKey = _ref.recentUsedColorsKey,
|
|
22
|
+
lastUsedColorKey = _ref.lastUsedColorKey,
|
|
21
23
|
text = _ref.text,
|
|
22
24
|
defaultColorTip = _ref.defaultColorTip,
|
|
23
25
|
defaultColor = _ref.defaultColor;
|
|
24
26
|
var popoverRef = useRef(null);
|
|
25
27
|
var moreColorsPopoverRef = useRef(null);
|
|
26
|
-
var _useState = useState(LocalStorage.getItem(
|
|
28
|
+
var _useState = useState(LocalStorage.getItem(lastUsedColorKey, '')),
|
|
27
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _useState3 = useState(
|
|
30
|
+
lastUsedColor = _useState2[0],
|
|
31
|
+
setLastUseColor = _useState2[1];
|
|
32
|
+
var _useState3 = useState(LocalStorage.getItem(recentUsedColorsKey, DEFAULT_RECENT_USED_COLORS)),
|
|
31
33
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
recentUsedColors = _useState4[0],
|
|
35
|
+
setRecentUsedColors = _useState4[1];
|
|
34
36
|
var _useState5 = useState(false),
|
|
35
37
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
isShowMenu = _useState6[0],
|
|
39
|
+
setMenuShow = _useState6[1];
|
|
40
|
+
var _useState7 = useState(false),
|
|
41
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
42
|
+
isPickerShow = _useState8[0],
|
|
43
|
+
setPickerShow = _useState8[1];
|
|
38
44
|
var onSetColor = useCallback(function (color) {
|
|
39
45
|
var shouldClose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
40
|
-
var validColor = color ||
|
|
46
|
+
var validColor = color || '';
|
|
41
47
|
setColor(validColor);
|
|
42
|
-
if (validColor !==
|
|
48
|
+
if (validColor !== '' && recentUsedColors[0] !== validColor) {
|
|
43
49
|
var newRecentUsedColors = recentUsedColors.slice(0, 9);
|
|
44
50
|
newRecentUsedColors.unshift(validColor);
|
|
45
|
-
LocalStorage.setItem(
|
|
51
|
+
LocalStorage.setItem(recentUsedColorsKey, newRecentUsedColors);
|
|
46
52
|
setRecentUsedColors(newRecentUsedColors);
|
|
47
53
|
}
|
|
54
|
+
LocalStorage.setItem(lastUsedColorKey, validColor);
|
|
55
|
+
setLastUseColor(validColor);
|
|
48
56
|
if (shouldClose) {
|
|
49
57
|
popoverRef.current.toggle();
|
|
50
58
|
setMenuShow(!isShowMenu);
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
-
}, [recentUsedColors,
|
|
62
|
+
}, [recentUsedColors, recentUsedColorsKey, isShowMenu, isPickerShow]);
|
|
55
63
|
var setColorProxy = useCallback(function (event) {
|
|
56
64
|
if (event.target.className.includes('sdoc-color-item')) {
|
|
57
65
|
var color = event.target.dataset.color;
|
|
@@ -59,7 +67,7 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
-
}, [recentUsedColors,
|
|
70
|
+
}, [recentUsedColors, recentUsedColorsKey, isShowMenu, isPickerShow]);
|
|
63
71
|
var toggle = useCallback(function () {
|
|
64
72
|
if (isPickerShow) return;
|
|
65
73
|
popoverRef.current.toggle();
|
|
@@ -84,7 +92,8 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
84
92
|
|
|
85
93
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
94
|
}, []);
|
|
87
|
-
var validClassName = classnames(className, 'sdoc-color-menu', {
|
|
95
|
+
var validClassName = classnames(className, 'sdoc-color-menu sdoc-menu-with-dropdown', {
|
|
96
|
+
'menu-show': isShowMenu,
|
|
88
97
|
'disabled': disabled,
|
|
89
98
|
'rich-icon-btn d-flex': isRichEditor,
|
|
90
99
|
'rich-icon-btn-disabled': isRichEditor && disabled,
|
|
@@ -104,28 +113,30 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
104
113
|
id: buttonId,
|
|
105
114
|
disabled: disabled
|
|
106
115
|
}, /*#__PURE__*/React.createElement("div", {
|
|
107
|
-
className: classnames('
|
|
108
|
-
'
|
|
116
|
+
className: classnames('last-used-color-container sdoc-menu-with-dropdown-icon', {
|
|
117
|
+
'disabled': disabled
|
|
109
118
|
}),
|
|
110
119
|
onClick: setRecentUsedColor
|
|
111
120
|
}, /*#__PURE__*/React.createElement("i", {
|
|
112
121
|
className: classnames(iconClass, 'sdoc-color-icon')
|
|
113
122
|
}), /*#__PURE__*/React.createElement("div", {
|
|
114
|
-
className: "
|
|
123
|
+
className: "last-used-color",
|
|
115
124
|
style: {
|
|
116
|
-
backgroundColor:
|
|
125
|
+
backgroundColor: lastUsedColor || 'unset'
|
|
117
126
|
}
|
|
118
|
-
})), /*#__PURE__*/React.createElement("
|
|
127
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
119
128
|
id: id,
|
|
120
|
-
className: "sdoc-color-toggle
|
|
121
|
-
}
|
|
129
|
+
className: "sdoc-color-toggle sdoc-menu-with-dropdown-triangle"
|
|
130
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
131
|
+
className: "sdoc-menu-with-dropdown-triangle-icon sdocfont sdoc-".concat(isShowMenu ? 'caret-up' : 'drop-down')
|
|
132
|
+
}))), text && /*#__PURE__*/React.createElement(UncontrolledTooltip, {
|
|
122
133
|
target: buttonId,
|
|
123
134
|
fade: false,
|
|
124
135
|
placement: "bottom",
|
|
125
136
|
delay: 0
|
|
126
137
|
}, t(text)), !disabled && /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
127
138
|
target: id,
|
|
128
|
-
className:
|
|
139
|
+
className: classnames('sdoc-color-menu-popover', popoverClassName),
|
|
129
140
|
trigger: "legacy",
|
|
130
141
|
placement: "bottom-start",
|
|
131
142
|
hideArrow: true,
|
|
@@ -150,7 +161,7 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
150
161
|
return /*#__PURE__*/React.createElement(ColorItem, {
|
|
151
162
|
key: "default-color-".concat(index),
|
|
152
163
|
color: color,
|
|
153
|
-
|
|
164
|
+
lastUsedColor: lastUsedColor
|
|
154
165
|
});
|
|
155
166
|
})), /*#__PURE__*/React.createElement("div", {
|
|
156
167
|
className: "sdoc-color-standard-colors-container"
|
|
@@ -163,7 +174,7 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
163
174
|
return /*#__PURE__*/React.createElement(ColorItem, {
|
|
164
175
|
key: "standard-color-".concat(index),
|
|
165
176
|
color: color,
|
|
166
|
-
|
|
177
|
+
lastUsedColor: lastUsedColor
|
|
167
178
|
});
|
|
168
179
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
169
180
|
className: "sdoc-color-recent-used-colors-container"
|
|
@@ -202,7 +213,7 @@ var ColorMenu = function ColorMenu(_ref) {
|
|
|
202
213
|
onClick: onClick
|
|
203
214
|
}, /*#__PURE__*/React.createElement(ChromePicker, {
|
|
204
215
|
disableAlpha: true,
|
|
205
|
-
color:
|
|
216
|
+
color: lastUsedColor || '',
|
|
206
217
|
onChange: onChange
|
|
207
218
|
}))))));
|
|
208
219
|
};
|
|
@@ -4,12 +4,12 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
7
|
-
var
|
|
8
|
-
_inherits(
|
|
9
|
-
var _super = _createSuper(
|
|
10
|
-
function
|
|
7
|
+
var ElementPopover = /*#__PURE__*/function (_React$Component) {
|
|
8
|
+
_inherits(ElementPopover, _React$Component);
|
|
9
|
+
var _super = _createSuper(ElementPopover);
|
|
10
|
+
function ElementPopover(props) {
|
|
11
11
|
var _this;
|
|
12
|
-
_classCallCheck(this,
|
|
12
|
+
_classCallCheck(this, ElementPopover);
|
|
13
13
|
_this = _super.call(this, props);
|
|
14
14
|
_this.state = {
|
|
15
15
|
isMounted: false
|
|
@@ -18,9 +18,12 @@ var ModalPortal = /*#__PURE__*/function (_React$Component) {
|
|
|
18
18
|
if (props.className) {
|
|
19
19
|
_this.el.className = props.className;
|
|
20
20
|
}
|
|
21
|
+
if (props.style) {
|
|
22
|
+
_this.el.style = props.style;
|
|
23
|
+
}
|
|
21
24
|
return _this;
|
|
22
25
|
}
|
|
23
|
-
_createClass(
|
|
26
|
+
_createClass(ElementPopover, [{
|
|
24
27
|
key: "componentDidMount",
|
|
25
28
|
value: function componentDidMount() {
|
|
26
29
|
document.body.appendChild(this.el);
|
|
@@ -36,6 +39,6 @@ var ModalPortal = /*#__PURE__*/function (_React$Component) {
|
|
|
36
39
|
return ReactDOM.createPortal(this.props.children, this.el);
|
|
37
40
|
}
|
|
38
41
|
}]);
|
|
39
|
-
return
|
|
42
|
+
return ElementPopover;
|
|
40
43
|
}(React.Component);
|
|
41
|
-
export default
|
|
44
|
+
export default ElementPopover;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
.menu-group {
|
|
2
|
+
height: 100%;
|
|
3
|
+
padding: 6px 0 6px 10px;
|
|
4
|
+
font-size: 0.75rem;
|
|
5
|
+
border-right: 1px solid #e5e6e8;
|
|
6
|
+
color: #555555;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.menu-group .menu-group-item {
|
|
13
|
+
width: 30px;
|
|
14
|
+
height: 30px;
|
|
15
|
+
line-height: 30px;
|
|
16
|
+
margin-right: 10px;
|
|
17
|
+
border: none !important;
|
|
18
|
+
color: #555555;
|
|
19
|
+
background-color: #fff;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.menu-group .menu-group-item:disabled {
|
|
23
|
+
color: #999;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.menu-group .menu-group-item:hover {
|
|
27
|
+
background-color: #e5e5e5;
|
|
28
|
+
border-radius: 2px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.menu-group .menu-group-item[data-active='true'] {
|
|
32
|
+
color: #eb8205;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.menu-group .menu-group-item .sdocfont {
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* sdoc-menu-with-dropdown */
|
|
40
|
+
.menu-group .menu-group-item.sdoc-menu-with-dropdown {
|
|
41
|
+
width: 36px;
|
|
42
|
+
height: 30px;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
border: 0 !important;
|
|
47
|
+
padding: 0 !important;
|
|
48
|
+
margin-right: 10px;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.menu-group .menu-group-item.sdoc-menu-with-dropdown.disabled {
|
|
53
|
+
color: #999;
|
|
54
|
+
width: 24px !important;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sdoc-menu-with-dropdown:not(.disabled):hover {
|
|
58
|
+
background: #e5e5e5;
|
|
59
|
+
border-radius: 2px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.sdoc-menu-with-dropdown .sdoc-menu-with-dropdown-icon {
|
|
63
|
+
width: 24px;
|
|
64
|
+
height: 30px;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.sdoc-menu-with-dropdown .sdoc-menu-with-dropdown-icon .sdocfont {
|
|
71
|
+
font-size: 14px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.sdoc-menu-with-dropdown .sdoc-menu-with-dropdown-triangle {
|
|
75
|
+
width: 12px;
|
|
76
|
+
height: 30px;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.sdoc-menu-with-dropdown .sdoc-menu-with-dropdown-triangle .sdoc-menu-with-dropdown-triangle-icon {
|
|
83
|
+
font-size: 14px;
|
|
84
|
+
transform: scale(.8);
|
|
85
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
4
|
+
var MoreDropdown = function MoreDropdown(_ref) {
|
|
5
|
+
var className = _ref.className,
|
|
6
|
+
disabled = _ref.disabled,
|
|
7
|
+
isRichEditor = _ref.isRichEditor,
|
|
8
|
+
children = _ref.children;
|
|
9
|
+
var validClassName = classnames(className, 'sdoc-more-text-button', {
|
|
10
|
+
'disabled': disabled,
|
|
11
|
+
'rich-icon-btn': isRichEditor,
|
|
12
|
+
'rich-icon-btn-disabled': isRichEditor && disabled,
|
|
13
|
+
'rich-icon-btn-hover': isRichEditor && !disabled,
|
|
14
|
+
'btn btn-icon btn-secondary btn-active': !isRichEditor
|
|
15
|
+
});
|
|
16
|
+
var buttonId = 'sdoc-more-text-operations';
|
|
17
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
18
|
+
className: validClassName,
|
|
19
|
+
type: "button",
|
|
20
|
+
id: buttonId
|
|
21
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
22
|
+
className: "sdocfont sdoc-more"
|
|
23
|
+
})), /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
24
|
+
target: buttonId,
|
|
25
|
+
className: "sdoc-menu-popover sdoc-dropdown-menu",
|
|
26
|
+
trigger: "legacy",
|
|
27
|
+
placement: "bottom-end",
|
|
28
|
+
hideArrow: true,
|
|
29
|
+
fade: false
|
|
30
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "menu-group"
|
|
32
|
+
}, children)));
|
|
33
|
+
};
|
|
34
|
+
MoreDropdown.defaultProps = {
|
|
35
|
+
isRichEditor: true,
|
|
36
|
+
className: 'menu-group-item'
|
|
37
|
+
};
|
|
38
|
+
export default MoreDropdown;
|
|
@@ -72,7 +72,8 @@ export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CO
|
|
|
72
72
|
text: 'Highlight_color',
|
|
73
73
|
type: HIGHLIGHT_COLOR,
|
|
74
74
|
isColor: true,
|
|
75
|
-
|
|
75
|
+
recentUsedColorsKey: 'sdoc-recent-used-highlight-colors',
|
|
76
|
+
lastUsedColorKey: 'sdoc-last-used-highlight-color'
|
|
76
77
|
}, {
|
|
77
78
|
id: "sdoc-font-".concat(COLOR),
|
|
78
79
|
iconClass: 'sdocfont sdoc-font-color',
|
|
@@ -80,7 +81,8 @@ export var MENUS_CONFIG_MAP = (_MENUS_CONFIG_MAP = {}, _defineProperty(_MENUS_CO
|
|
|
80
81
|
type: COLOR,
|
|
81
82
|
defaultColor: DEFAULT_FONT_COLOR,
|
|
82
83
|
isColor: true,
|
|
83
|
-
|
|
84
|
+
recentUsedColorsKey: 'sdoc-recent-used-font-colors',
|
|
85
|
+
lastUsedColorKey: 'sdoc-last-used-font-color'
|
|
84
86
|
}]), _defineProperty(_MENUS_CONFIG_MAP, TEXT_STYLE_MORE, [{
|
|
85
87
|
id: STRIKETHROUGH,
|
|
86
88
|
iconClass: 'sdocfont sdoc-strikethrough',
|
|
@@ -149,4 +151,5 @@ export var ADDED_STYLE = {
|
|
|
149
151
|
export var HEADER_TYPE_ARRAY = ['header1', 'header2', 'header3', 'header4', 'header5', 'header6'];
|
|
150
152
|
export var LIST_TYPE_ARRAY = ['unordered_list', 'ordered_list'];
|
|
151
153
|
export var TRANSPARENT = 'transparent';
|
|
154
|
+
export var CLIPBOARD_FORMAT_KEY = 'x-slate-fragment';
|
|
152
155
|
export { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, BOLD, ITALIC, UNDERLINE, STRIKETHROUGH, SUPERSCRIPT, SUBSCRIPT, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, LIST_LIC, CHECK_LIST, CHECK_LIST_ITEM, LINK, HTML, CODE_BLOCK, CODE_LINE, IMAGE, TABLE, TABLE_CELL, TABLE_ROW, FORMULA, COLUMN, TEXT_STYLE, TEXT_STYLE_MORE, BOLD_ITALIC, TEXT_ALIGN, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, ELEMENT_TYPE, KEYBOARD, DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_COLORS, CLEAR_FORMAT, DEFAULT_FONT_COLOR };
|
|
@@ -4,7 +4,7 @@ import { withHistory } from '@seafile/slate-history';
|
|
|
4
4
|
import Plugins from './plugins';
|
|
5
5
|
import renderElement from './render/render-element';
|
|
6
6
|
import renderLeaf from './render/render-leaf';
|
|
7
|
-
import Toolbar from './toolbar';
|
|
7
|
+
import { Toolbar, ContextToolbar } from './toolbar';
|
|
8
8
|
var baseEditor = withHistory(withReact(createEditor()));
|
|
9
9
|
var defaultEditor = Plugins.reduce(function (editor, pluginItem) {
|
|
10
10
|
var withPlugin = pluginItem.editorPlugin;
|
|
@@ -14,4 +14,4 @@ var defaultEditor = Plugins.reduce(function (editor, pluginItem) {
|
|
|
14
14
|
return editor;
|
|
15
15
|
}, baseEditor);
|
|
16
16
|
export default defaultEditor;
|
|
17
|
-
export { renderLeaf, renderElement, Toolbar };
|
|
17
|
+
export { renderLeaf, renderElement, Toolbar, ContextToolbar };
|
|
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { BLOCKQUOTE, MENUS_CONFIG_MAP } from '../../../constants';
|
|
8
|
-
import { MenuItem } from '../../../
|
|
8
|
+
import { MenuItem } from '../../../commons';
|
|
9
9
|
import { getBlockQuoteType, isMenuDisabled, setBlockQuoteType } from '../helpers';
|
|
10
10
|
var QuoteMenu = /*#__PURE__*/function (_React$Component) {
|
|
11
11
|
_inherits(QuoteMenu, _React$Component);
|
|
@@ -5,7 +5,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { CHECK_LIST, CHECK_LIST_ITEM, MENUS_CONFIG_MAP, PARAGRAPH } from '../../../constants';
|
|
8
|
-
import { MenuItem } from '../../../
|
|
8
|
+
import { MenuItem } from '../../../commons';
|
|
9
9
|
import { isMenuDisabled, setCheckListItemType, getCheckListItemType } from '../helpers';
|
|
10
10
|
var CheckListMenu = /*#__PURE__*/function (_React$Component) {
|
|
11
11
|
_inherits(CheckListMenu, _React$Component);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
3
|
import { CLEAR_FORMAT, MENUS_CONFIG_MAP } from '../../../constants';
|
|
4
|
-
import { MenuItem } from '../../../
|
|
4
|
+
import { MenuItem } from '../../../commons';
|
|
5
5
|
import { isMenuDisabled, clearStyles } from '../helpers';
|
|
6
6
|
var menuConfig = MENUS_CONFIG_MAP[CLEAR_FORMAT];
|
|
7
7
|
var ClearFormatMenu = function ClearFormatMenu(_ref) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
|
-
import { createPortal } from 'react-dom';
|
|
4
3
|
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import { ElementPopover } from '../../../commons/';
|
|
5
5
|
import { genCodeLangs } from '../prismjs';
|
|
6
6
|
import './index.css';
|
|
7
7
|
var CodeBlockHoverMenu = function CodeBlockHoverMenu(_ref) {
|
|
@@ -68,7 +68,7 @@ var CodeBlockHoverMenu = function CodeBlockHoverMenu(_ref) {
|
|
|
68
68
|
}).text;
|
|
69
69
|
setSelectedLanguageText(selectedLanguageText);
|
|
70
70
|
}, [language]);
|
|
71
|
-
return /*#__PURE__*/React.createElement(
|
|
71
|
+
return /*#__PURE__*/React.createElement(ElementPopover, null, /*#__PURE__*/React.createElement("div", {
|
|
72
72
|
className: "sdoc-code-block-hover-menu-container",
|
|
73
73
|
style: menuPosition
|
|
74
74
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -110,6 +110,6 @@ var CodeBlockHoverMenu = function CodeBlockHoverMenu(_ref) {
|
|
|
110
110
|
}, /*#__PURE__*/React.createElement("i", {
|
|
111
111
|
className: "sdocfont sdoc-check-square icon-font"
|
|
112
112
|
})), item.text);
|
|
113
|
-
}))))))
|
|
113
|
+
}))))));
|
|
114
114
|
};
|
|
115
115
|
export default withTranslation('sdoc-editor')(CodeBlockHoverMenu);
|
|
@@ -6,7 +6,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { focusEditor } from '../../../core';
|
|
8
8
|
import { CODE_BLOCK, MENUS_CONFIG_MAP } from '../../../constants';
|
|
9
|
-
import { MenuItem } from '../../../
|
|
9
|
+
import { MenuItem } from '../../../commons';
|
|
10
10
|
import { getSelectCodeElem, isMenuDisabled, changeToCodeBlock, changeToPlainText } from '../helpers';
|
|
11
11
|
var CodeBlockMenu = /*#__PURE__*/function (_React$Component) {
|
|
12
12
|
_inherits(CodeBlockMenu, _React$Component);
|
|
@@ -8,7 +8,7 @@ import { withTranslation } from 'react-i18next';
|
|
|
8
8
|
import { insertImage, isInsertImageMenuDisabled } from '../helpers';
|
|
9
9
|
import context from '../../../../../context';
|
|
10
10
|
import { IMAGE, MENUS_CONFIG_MAP } from '../../../constants';
|
|
11
|
-
import { MenuItem } from '../../../
|
|
11
|
+
import { MenuItem } from '../../../commons';
|
|
12
12
|
import InsertWebImageDialog from '../dialogs/insert-web-image-dialog';
|
|
13
13
|
import './style.css';
|
|
14
14
|
var ImageMenu = /*#__PURE__*/function (_React$Component) {
|
|
@@ -6,7 +6,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { LINK, MENUS_CONFIG_MAP } from '../../../constants';
|
|
8
8
|
import { getEditorString } from '../../../core';
|
|
9
|
-
import { MenuItem } from '../../../
|
|
9
|
+
import { MenuItem } from '../../../commons';
|
|
10
10
|
import { getLinkType, isMenuDisabled } from '../helpers';
|
|
11
11
|
import AddLinkDialog from './add-link-dialog';
|
|
12
12
|
var LinkMenu = /*#__PURE__*/function (_React$Component) {
|
|
@@ -3,6 +3,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { Range } from '@seafile/slate';
|
|
6
7
|
import { unWrapLinkNode } from './helpers';
|
|
7
8
|
import AddLinkDialog from './menu/add-link-dialog';
|
|
8
9
|
import LinkHoverComponent from './menu/hover-link-dialog';
|
|
@@ -96,7 +97,7 @@ var LinkHoverMenuComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
96
97
|
url: element.href,
|
|
97
98
|
title: element.title,
|
|
98
99
|
onLinkDialogToggle: this.onLinkDialogToggle
|
|
99
|
-
}), isShowLinkMenu && /*#__PURE__*/React.createElement(LinkHoverComponent, {
|
|
100
|
+
}), isShowLinkMenu && Range.isCollapsed(editor.selection) && /*#__PURE__*/React.createElement(LinkHoverComponent, {
|
|
100
101
|
menuPosition: menuPosition,
|
|
101
102
|
editor: editor,
|
|
102
103
|
href: element.href,
|