@seafile/sdoc-editor 0.1.80 → 0.1.81-test
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/api/seafile-api.js +6 -0
- package/dist/basic-sdk/assets/css/dropdown-menu.css +23 -0
- package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +2 -0
- package/dist/basic-sdk/comment/comment-item.js +1 -3
- package/dist/basic-sdk/comment/style.css +13 -6
- package/dist/basic-sdk/editor.js +5 -2
- package/dist/basic-sdk/extension/constants/index.js +2 -0
- package/dist/basic-sdk/extension/core/queries/index.js +15 -3
- package/dist/basic-sdk/extension/plugins/blockquote/helpers.js +28 -8
- package/dist/basic-sdk/extension/plugins/blockquote/menu/index.js +2 -3
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +24 -12
- package/dist/basic-sdk/extension/plugins/header/menu/style.css +0 -17
- package/dist/basic-sdk/extension/plugins/header/plugin.js +20 -4
- package/dist/basic-sdk/extension/plugins/image/helpers.js +1 -5
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +1 -1
- package/dist/basic-sdk/extension/plugins/table/helpers.js +11 -0
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/common-menu.js +1 -4
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.css +0 -4
- package/dist/basic-sdk/extension/plugins/table/menu/active-table-menu/index.js +14 -14
- package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js +13 -0
- package/dist/basic-sdk/extension/plugins/text-align/menu/index.js +17 -5
- package/dist/basic-sdk/extension/plugins/text-align/menu/style.css +0 -12
- package/dist/basic-sdk/socket/socket-manager.js +3 -0
- package/dist/basic-sdk/socket/with-socket-io.js +2 -2
- package/dist/basic-sdk/views/viewer.js +1 -0
- package/dist/components/doc-info/index.js +12 -5
- package/dist/components/doc-operations/index.js +10 -3
- package/dist/components/doc-operations/revision-operations/index.js +16 -0
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.css +58 -0
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.js +56 -0
- package/dist/components/doc-operations/revision-operations/publish-button.js +28 -0
- package/dist/components/doc-operations/{revision-operations.js → revision-operations/revision-operations.js} +3 -3
- package/dist/components/doc-operations/revision-operations/view-changes/index.css +3 -0
- package/dist/components/doc-operations/revision-operations/view-changes/index.js +26 -0
- package/dist/components/draft-dropdown/index.js +77 -0
- package/dist/components/draft-dropdown/style.css +43 -0
- package/dist/components/switch/index.css +14 -0
- package/dist/components/switch/index.js +28 -0
- package/dist/components/tip-message/index.js +4 -1
- package/dist/config.js +16 -0
- package/dist/constants/index.js +1 -0
- package/dist/context.js +6 -0
- package/dist/pages/simple-editor.js +134 -116
- package/dist/pages/simple-viewer.js +5 -3
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +5 -1
- package/public/locales/zh-CN/sdoc-editor.json +4 -2
- package/public/media/sdoc-editor-font.css +6 -6
package/dist/api/seafile-api.js
CHANGED
|
@@ -62,6 +62,12 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
62
62
|
form.append('file_uuid', fileUuid);
|
|
63
63
|
return this._sendPostRequest(url, form);
|
|
64
64
|
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "getSeadocRevisionDownloadLinks",
|
|
67
|
+
value: function getSeadocRevisionDownloadLinks(docUuid) {
|
|
68
|
+
var url = '/api/v2.1/seadoc/revision/download-links/' + docUuid + '/';
|
|
69
|
+
return this.req.get(url);
|
|
70
|
+
}
|
|
65
71
|
}]);
|
|
66
72
|
return SeafileAPI;
|
|
67
73
|
}();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.sdoc-dropdown-menu {
|
|
2
|
+
padding: 8px 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.sdoc-dropdown-menu .sdoc-dropdown-menu-divider {
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 0;
|
|
8
|
+
margin: 0.5rem 0;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
border-top: 1px solid #e9ecef;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sdoc-dropdown-menu .sdoc-dropdown-menu-item {
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
height: 28px;
|
|
16
|
+
width: 100%;
|
|
17
|
+
padding: 4px 24px;
|
|
18
|
+
user-select: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sdoc-dropdown-menu .sdoc-dropdown-menu-item:hover {
|
|
22
|
+
background-color: rgb(245, 245, 245);
|
|
23
|
+
}
|
|
@@ -57,10 +57,12 @@
|
|
|
57
57
|
.sdoc-editor-container .article .image-size {
|
|
58
58
|
display: inline-block;
|
|
59
59
|
padding: 5px;
|
|
60
|
+
white-space: nowrap;
|
|
60
61
|
height: 22px;
|
|
61
62
|
position: absolute;
|
|
62
63
|
bottom: -25px;
|
|
63
64
|
left: 100%;
|
|
65
|
+
z-index: 1;
|
|
64
66
|
transform: translateX(5px);
|
|
65
67
|
border-radius: 3px;
|
|
66
68
|
line-height: 12px;
|
|
@@ -79,9 +79,7 @@ var CommentItem = function CommentItem(_ref) {
|
|
|
79
79
|
placement: "bottom-end",
|
|
80
80
|
hideArrow: true
|
|
81
81
|
}, /*#__PURE__*/React.createElement(PopoverBody, {
|
|
82
|
-
|
|
83
|
-
padding: '5px'
|
|
84
|
-
}
|
|
82
|
+
className: "sdoc-comment-menu"
|
|
85
83
|
}, /*#__PURE__*/React.createElement("div", {
|
|
86
84
|
className: "sdoc-popover-menu"
|
|
87
85
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -100,25 +100,32 @@
|
|
|
100
100
|
cursor: pointer;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
.sdoc-comment-menu {
|
|
104
|
+
padding: 0;
|
|
105
|
+
border-radius: 2px;
|
|
106
|
+
}
|
|
107
|
+
|
|
103
108
|
.sdoc-popover-menu {
|
|
104
109
|
background: rgb(255, 255, 255);
|
|
105
110
|
width: 130px;
|
|
111
|
+
padding: 8px 0;
|
|
106
112
|
height: auto;
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
.sdoc-popover-menu__item {
|
|
110
|
-
padding:
|
|
111
|
-
height:
|
|
112
|
-
|
|
116
|
+
padding: 4px 24px;
|
|
117
|
+
height: 28px;
|
|
118
|
+
vertical-align: middle;
|
|
113
119
|
font-size: 14px;
|
|
114
|
-
border-radius: 5px;
|
|
115
|
-
color: #0f141a;
|
|
116
120
|
background-color: transparent;
|
|
117
121
|
cursor: default;
|
|
122
|
+
color: #202428;
|
|
123
|
+
background-color: #fff;
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
.sdoc-popover-menu__item:hover {
|
|
121
|
-
background-color:
|
|
127
|
+
background-color: #20a0ff;
|
|
128
|
+
color: #fff;
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
.sdoc-comment-container .comment-list-container .comment-editor-wrapper {
|
package/dist/basic-sdk/editor.js
CHANGED
|
@@ -9,7 +9,7 @@ import SDocOutline from './outline';
|
|
|
9
9
|
import EventProxy from './utils/event-handler';
|
|
10
10
|
import { useCursors } from './cursor/use-cursors';
|
|
11
11
|
import EventBus from './utils/event-bus';
|
|
12
|
-
import { EXTERNAL_EVENT } from '../constants';
|
|
12
|
+
import { EXTERNAL_EVENT, PAGE_EDIT_AREA_WIDTH } from '../constants';
|
|
13
13
|
import { isAllInTable } from './extension/plugins/table/helpers';
|
|
14
14
|
import { SetNodeToDecorations } from './highlight-decorate/setNodeToDecorations';
|
|
15
15
|
import { ScrollContext } from './hooks/use-scroll-context';
|
|
@@ -19,6 +19,7 @@ import { usePipDecorate } from './decorates';
|
|
|
19
19
|
import { getCursorPosition, getDomHeight, getDomMarginTop } from './utils/dom-utils';
|
|
20
20
|
import './assets/css/layout.css';
|
|
21
21
|
import './assets/css/sdoc-editor-plugins.css';
|
|
22
|
+
import './assets/css/dropdown-menu.css';
|
|
22
23
|
var SDocEditor = function SDocEditor(_ref) {
|
|
23
24
|
var document = _ref.document,
|
|
24
25
|
config = _ref.config;
|
|
@@ -30,6 +31,7 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
30
31
|
}));
|
|
31
32
|
var cursors = document.cursors;
|
|
32
33
|
newEditor.cursors = cursors || {};
|
|
34
|
+
newEditor.width = PAGE_EDIT_AREA_WIDTH; // default width
|
|
33
35
|
return newEditor;
|
|
34
36
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
37
|
}, []);
|
|
@@ -61,7 +63,6 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
61
63
|
// useMount: init socket connection
|
|
62
64
|
useEffect(function () {
|
|
63
65
|
editor.openConnection();
|
|
64
|
-
editor.width = articleRef.current.children[0].clientWidth;
|
|
65
66
|
return function () {
|
|
66
67
|
editor.closeConnection();
|
|
67
68
|
};
|
|
@@ -71,6 +72,8 @@ var SDocEditor = function SDocEditor(_ref) {
|
|
|
71
72
|
// useMount: focus editor
|
|
72
73
|
useEffect(function () {
|
|
73
74
|
var timer = setTimeout(function () {
|
|
75
|
+
// real width
|
|
76
|
+
editor.width = articleRef.current.children[0].clientWidth;
|
|
74
77
|
focusEditor(editor);
|
|
75
78
|
}, 300);
|
|
76
79
|
return function () {
|
|
@@ -120,4 +120,6 @@ export var ADDED_STYLE = {
|
|
|
120
120
|
computed_bg_color: '#e6ffed',
|
|
121
121
|
color: 'rgb(137, 181, 66)'
|
|
122
122
|
};
|
|
123
|
+
export var HEADER_TYPE_ARRAY = ['header1', 'header2', 'header3', 'header4', 'header5', 'header6'];
|
|
124
|
+
export var LIST_TYPE_ARRAY = ['unordered_list', 'ordered_list'];
|
|
123
125
|
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 };
|
|
@@ -84,16 +84,28 @@ export var getSelectedNodeByType = function getSelectedNodeByType(editor, type)
|
|
|
84
84
|
nodeEntry = _Editor$nodes2[0];
|
|
85
85
|
return nodeEntry ? nodeEntry[0] : null;
|
|
86
86
|
};
|
|
87
|
-
export var
|
|
87
|
+
export var getSelectedNodeByTypes = function getSelectedNodeByTypes(editor, types) {
|
|
88
88
|
var match = function match(n) {
|
|
89
|
-
return getNodeType(n)
|
|
89
|
+
return types.includes(getNodeType(n));
|
|
90
90
|
};
|
|
91
91
|
var _Editor$nodes3 = Editor.nodes(editor, {
|
|
92
92
|
match: match,
|
|
93
|
-
universal:
|
|
93
|
+
universal: true
|
|
94
94
|
}),
|
|
95
95
|
_Editor$nodes4 = _slicedToArray(_Editor$nodes3, 1),
|
|
96
96
|
nodeEntry = _Editor$nodes4[0];
|
|
97
|
+
return nodeEntry ? nodeEntry[0] : null;
|
|
98
|
+
};
|
|
99
|
+
export var getSelectedNodeEntryByType = function getSelectedNodeEntryByType(editor, type) {
|
|
100
|
+
var match = function match(n) {
|
|
101
|
+
return getNodeType(n) === type;
|
|
102
|
+
};
|
|
103
|
+
var _Editor$nodes5 = Editor.nodes(editor, {
|
|
104
|
+
match: match,
|
|
105
|
+
universal: false
|
|
106
|
+
}),
|
|
107
|
+
_Editor$nodes6 = _slicedToArray(_Editor$nodes5, 1),
|
|
108
|
+
nodeEntry = _Editor$nodes6[0];
|
|
97
109
|
return nodeEntry ? nodeEntry : null;
|
|
98
110
|
};
|
|
99
111
|
export var getNodeEntries = function getNodeEntries(editor, options) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import { Editor, Transforms } from '@seafile/slate';
|
|
3
|
-
import
|
|
2
|
+
import { Editor, Transforms, Element } from '@seafile/slate';
|
|
3
|
+
import slugid from 'slugid';
|
|
4
|
+
import { BLOCKQUOTE, CHECK_LIST_ITEM, IMAGE, ORDERED_LIST, UNORDERED_LIST } from '../../constants';
|
|
4
5
|
import { focusEditor, getNodeType } from '../../core';
|
|
5
6
|
export var isMenuDisabled = function isMenuDisabled(editor) {
|
|
6
7
|
if (editor.selection == null) return true;
|
|
@@ -11,6 +12,11 @@ export var isMenuDisabled = function isMenuDisabled(editor) {
|
|
|
11
12
|
// Only available for p and blockquote
|
|
12
13
|
if (type === 'paragraph') return true;
|
|
13
14
|
if (type === 'blockquote') return true;
|
|
15
|
+
if (type === UNORDERED_LIST) return true;
|
|
16
|
+
if (type === ORDERED_LIST) return true;
|
|
17
|
+
if (type === CHECK_LIST_ITEM) return true;
|
|
18
|
+
if (type && type.startWith && type.startWith('header')) return true;
|
|
19
|
+
if (type === IMAGE) return true;
|
|
14
20
|
return false;
|
|
15
21
|
},
|
|
16
22
|
universal: true,
|
|
@@ -40,11 +46,25 @@ export var getBlockQuoteType = function getBlockQuoteType(editor) {
|
|
|
40
46
|
n = _match[0];
|
|
41
47
|
return getNodeType(n);
|
|
42
48
|
};
|
|
43
|
-
export var setBlockQuoteType = function setBlockQuoteType(editor,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
export var setBlockQuoteType = function setBlockQuoteType(editor, active) {
|
|
50
|
+
if (!active) {
|
|
51
|
+
var blockquoteNode = {
|
|
52
|
+
id: slugid.nice(),
|
|
53
|
+
type: BLOCKQUOTE
|
|
54
|
+
};
|
|
55
|
+
Transforms.wrapNodes(editor, blockquoteNode, {
|
|
56
|
+
mode: 'highest',
|
|
57
|
+
match: function match(n) {
|
|
58
|
+
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
Transforms.unwrapNodes(editor, {
|
|
63
|
+
mode: 'highest',
|
|
64
|
+
match: function match(n) {
|
|
65
|
+
return Element.isElement(n) && Editor.isBlock(editor, n);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
49
69
|
focusEditor(editor);
|
|
50
70
|
};
|
|
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
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
|
-
import { BLOCKQUOTE, MENUS_CONFIG_MAP
|
|
7
|
+
import { BLOCKQUOTE, MENUS_CONFIG_MAP } from '../../../constants';
|
|
8
8
|
import { MenuItem } from '../../../menu';
|
|
9
9
|
import { getBlockQuoteType, isMenuDisabled, setBlockQuoteType } from '../helpers';
|
|
10
10
|
var QuoteMenu = /*#__PURE__*/function (_React$Component) {
|
|
@@ -28,8 +28,7 @@ var QuoteMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
28
28
|
_this.onMouseDown = function (e) {
|
|
29
29
|
var editor = _this.props.editor;
|
|
30
30
|
var active = _this.isActive(editor);
|
|
31
|
-
|
|
32
|
-
setBlockQuoteType(editor, newType);
|
|
31
|
+
setBlockQuoteType(editor, active);
|
|
33
32
|
};
|
|
34
33
|
return _this;
|
|
35
34
|
}
|
|
@@ -16,12 +16,15 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
16
16
|
_classCallCheck(this, HeaderMenu);
|
|
17
17
|
_this = _super.call(this, props);
|
|
18
18
|
_this.registerEventHandler = function () {
|
|
19
|
-
document.addEventListener('click', _this.onHideHeaderMenu);
|
|
19
|
+
document.addEventListener('click', _this.onHideHeaderMenu, true);
|
|
20
20
|
};
|
|
21
21
|
_this.unregisterEventHandler = function () {
|
|
22
|
-
document.removeEventListener('click', _this.onHideHeaderMenu);
|
|
22
|
+
document.removeEventListener('click', _this.onHideHeaderMenu, true);
|
|
23
23
|
};
|
|
24
|
-
_this.onHideHeaderMenu = function () {
|
|
24
|
+
_this.onHideHeaderMenu = function (e) {
|
|
25
|
+
var menu = _this.menu;
|
|
26
|
+
var clickIsInMenu = menu && menu.contains(e.target) && menu !== e.target;
|
|
27
|
+
if (clickIsInMenu) return;
|
|
25
28
|
_this.setState({
|
|
26
29
|
isShowHeaderPopover: false
|
|
27
30
|
}, function () {
|
|
@@ -65,8 +68,16 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
65
68
|
|
|
66
69
|
// 执行命令
|
|
67
70
|
setHeaderType(editor, newType);
|
|
71
|
+
_this.setState({
|
|
72
|
+
isShowHeaderPopover: false
|
|
73
|
+
}, function () {
|
|
74
|
+
_this.unregisterEventHandler();
|
|
75
|
+
});
|
|
68
76
|
};
|
|
69
77
|
};
|
|
78
|
+
_this.setMenuRef = function (ref) {
|
|
79
|
+
_this.menu = ref;
|
|
80
|
+
};
|
|
70
81
|
_this.state = {
|
|
71
82
|
isShowHeaderPopover: false
|
|
72
83
|
};
|
|
@@ -92,29 +103,30 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
92
103
|
}, t(HEADER_TITLE_MAP[headerType])), !disabled && /*#__PURE__*/React.createElement("span", {
|
|
93
104
|
className: headerIconClass
|
|
94
105
|
})), isShowHeaderPopover && /*#__PURE__*/React.createElement("div", {
|
|
95
|
-
|
|
106
|
+
ref: this.setMenuRef,
|
|
107
|
+
className: "header-popover sdoc-dropdown-menu"
|
|
96
108
|
}, /*#__PURE__*/React.createElement("div", {
|
|
97
|
-
className: "
|
|
109
|
+
className: "sdoc-dropdown-menu-item",
|
|
98
110
|
onClick: this.onMouseDown(PARAGRAPH)
|
|
99
111
|
}, t(HEADER_TITLE_MAP.paragraph)), /*#__PURE__*/React.createElement("div", {
|
|
100
|
-
className: "
|
|
112
|
+
className: "sdoc-dropdown-menu-divider"
|
|
101
113
|
}), /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
className: "
|
|
114
|
+
className: "sdoc-dropdown-menu-item",
|
|
103
115
|
onClick: this.onMouseDown(HEADER1)
|
|
104
116
|
}, t(HEADER_TITLE_MAP.header1)), /*#__PURE__*/React.createElement("div", {
|
|
105
|
-
className: "
|
|
117
|
+
className: "sdoc-dropdown-menu-item",
|
|
106
118
|
onClick: this.onMouseDown(HEADER2)
|
|
107
119
|
}, t(HEADER_TITLE_MAP.header2)), /*#__PURE__*/React.createElement("div", {
|
|
108
|
-
className: "
|
|
120
|
+
className: "sdoc-dropdown-menu-item",
|
|
109
121
|
onClick: this.onMouseDown(HEADER3)
|
|
110
122
|
}, t(HEADER_TITLE_MAP.header3)), /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: "
|
|
123
|
+
className: "sdoc-dropdown-menu-item",
|
|
112
124
|
onClick: this.onMouseDown(HEADER4)
|
|
113
125
|
}, t(HEADER_TITLE_MAP.header4)), /*#__PURE__*/React.createElement("div", {
|
|
114
|
-
className: "
|
|
126
|
+
className: "sdoc-dropdown-menu-item",
|
|
115
127
|
onClick: this.onMouseDown(HEADER5)
|
|
116
128
|
}, t(HEADER_TITLE_MAP.header5)), /*#__PURE__*/React.createElement("div", {
|
|
117
|
-
className: "
|
|
129
|
+
className: "sdoc-dropdown-menu-item",
|
|
118
130
|
onClick: this.onMouseDown(HEADER6)
|
|
119
131
|
}, t(HEADER_TITLE_MAP.header6))));
|
|
120
132
|
}
|
|
@@ -50,20 +50,3 @@
|
|
|
50
50
|
align-items: flex-start;
|
|
51
51
|
z-index: 10;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
.header-menu .header-popover .header-divider {
|
|
55
|
-
width: 100%;
|
|
56
|
-
border-top: 1px solid #e5e5e5;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.header-menu .header-popover .header-menu-item {
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
height: 30px;
|
|
62
|
-
width: 100%;
|
|
63
|
-
padding: 4px 24px;
|
|
64
|
-
user-select: none;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.header-menu .header-popover .header-menu-item:hover {
|
|
68
|
-
background-color: rgb(245, 245, 245);
|
|
69
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import { Editor, Element, Transforms } from '@seafile/slate';
|
|
3
|
-
import { PARAGRAPH } from '../../constants';
|
|
4
|
-
import { generateEmptyElement } from '../../core';
|
|
2
|
+
import { Editor, Element, Transforms, Node } from '@seafile/slate';
|
|
3
|
+
import { PARAGRAPH, HEADER_TYPE_ARRAY, LIST_TYPE_ARRAY } from '../../constants';
|
|
4
|
+
import { generateEmptyElement, getSelectedNodeByTypes } from '../../core';
|
|
5
5
|
var isSelectionAtLineEnd = function isSelectionAtLineEnd(editor, path) {
|
|
6
6
|
var selection = editor.selection;
|
|
7
7
|
if (!selection) return false;
|
|
@@ -9,7 +9,9 @@ var isSelectionAtLineEnd = function isSelectionAtLineEnd(editor, path) {
|
|
|
9
9
|
return isAtLineEnd;
|
|
10
10
|
};
|
|
11
11
|
var withHeader = function withHeader(editor) {
|
|
12
|
-
var insertBreak = editor.insertBreak
|
|
12
|
+
var insertBreak = editor.insertBreak,
|
|
13
|
+
insertFragment = editor.insertFragment,
|
|
14
|
+
insertText = editor.insertText;
|
|
13
15
|
var newEditor = editor;
|
|
14
16
|
|
|
15
17
|
// Rewrite insertBreak - insert paragraph when carriage return at the end of header
|
|
@@ -51,6 +53,20 @@ var withHeader = function withHeader(editor) {
|
|
|
51
53
|
insertBreak();
|
|
52
54
|
}
|
|
53
55
|
};
|
|
56
|
+
newEditor.insertFragment = function (data) {
|
|
57
|
+
var headerNode = getSelectedNodeByTypes(editor, HEADER_TYPE_ARRAY);
|
|
58
|
+
var headerText = Node.string(headerNode || {
|
|
59
|
+
children: []
|
|
60
|
+
});
|
|
61
|
+
var isSingleListItem = data.length === 1 && data[0].children.length === 1 && LIST_TYPE_ARRAY.includes(data[0].type);
|
|
62
|
+
// Insert a list item when the header is empty, insert only the text
|
|
63
|
+
if (headerNode && headerText.length === 0 && isSingleListItem) {
|
|
64
|
+
var text = Node.string(data[0]);
|
|
65
|
+
insertText(text);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
return insertFragment(data);
|
|
69
|
+
};
|
|
54
70
|
return newEditor;
|
|
55
71
|
};
|
|
56
72
|
export default withHeader;
|
|
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import urlJoin from 'url-join';
|
|
4
4
|
import { Editor, Range, Transforms } from '@seafile/slate';
|
|
5
|
-
import {
|
|
5
|
+
import { CODE_BLOCK, IMAGE, ORDERED_LIST, UNORDERED_LIST } from '../../constants';
|
|
6
6
|
import { generateEmptyElement, getNodeType, isTextNode, getParentNode } from '../../core';
|
|
7
7
|
import context from '../../../../context';
|
|
8
8
|
export var isInsertImageMenuDisabled = function isInsertImageMenuDisabled(editor) {
|
|
@@ -16,14 +16,10 @@ export var isInsertImageMenuDisabled = function isInsertImageMenuDisabled(editor
|
|
|
16
16
|
var parentNode = getParentNode(editor.children, n.id);
|
|
17
17
|
type = getNodeType(parentNode);
|
|
18
18
|
}
|
|
19
|
-
if (type === ELEMENT_TYPE.TABLE) return true;
|
|
20
|
-
if (type === ELEMENT_TYPE.TABLE_ROW) return true;
|
|
21
|
-
if (type === ELEMENT_TYPE.TABLE_CELL) return true;
|
|
22
19
|
if (type === CODE_BLOCK) return true;
|
|
23
20
|
if (type === ORDERED_LIST) return true;
|
|
24
21
|
if (type === UNORDERED_LIST) return true;
|
|
25
22
|
if (type.startsWith('header')) return true;
|
|
26
|
-
if (type === BLOCKQUOTE) return true;
|
|
27
23
|
if (Editor.isVoid(editor, n)) return true;
|
|
28
24
|
return false;
|
|
29
25
|
},
|
|
@@ -464,4 +464,15 @@ export var getFirstTableCell = function getFirstTableCell(element) {
|
|
|
464
464
|
tableCellElement = tableCellElement.parentNode;
|
|
465
465
|
}
|
|
466
466
|
return tableCellElement;
|
|
467
|
+
};
|
|
468
|
+
export var rowElementHasImage = function rowElementHasImage(element) {
|
|
469
|
+
if (!element) return false;
|
|
470
|
+
if (!Array.isArray(element.children) || element.children.length === 0) return false;
|
|
471
|
+
return element.children.some(function (child) {
|
|
472
|
+
if (child.type === ELEMENT_TYPE.IMAGE) return true;
|
|
473
|
+
if (ObjectUtils.hasProperty(child, 'children')) {
|
|
474
|
+
return rowElementHasImage(child);
|
|
475
|
+
}
|
|
476
|
+
return false;
|
|
477
|
+
});
|
|
467
478
|
};
|
|
@@ -21,9 +21,6 @@ var CommonMenu = /*#__PURE__*/function (_Component) {
|
|
|
21
21
|
itemClass = "rich-icon-btn d-flex ".concat(disabled ? 'rich-icon-btn-disabled' : 'rich-icon-btn-hover');
|
|
22
22
|
return itemClass + ' ' + className;
|
|
23
23
|
};
|
|
24
|
-
_this.hidePopover = function () {
|
|
25
|
-
_this.ref && _this.ref.toggle && _this.ref.toggle();
|
|
26
|
-
};
|
|
27
24
|
_this.setRef = function (ref) {
|
|
28
25
|
_this.ref = ref;
|
|
29
26
|
if (!_this.ref) return;
|
|
@@ -65,7 +62,7 @@ var CommonMenu = /*#__PURE__*/function (_Component) {
|
|
|
65
62
|
hideArrow: true,
|
|
66
63
|
ref: this.setRef
|
|
67
64
|
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
-
className: "sdoc-
|
|
65
|
+
className: "sdoc-dropdown-menu"
|
|
69
66
|
}, children)));
|
|
70
67
|
}
|
|
71
68
|
}]);
|
|
@@ -59,18 +59,18 @@ var ActiveTableMenu = /*#__PURE__*/function (_Component) {
|
|
|
59
59
|
ref: function ref(_ref) {
|
|
60
60
|
return _this.textAlignRef = _ref;
|
|
61
61
|
}
|
|
62
|
-
}, /*#__PURE__*/React.createElement("
|
|
63
|
-
className: "dropdown-item",
|
|
62
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: "sdoc-dropdown-menu-item",
|
|
64
64
|
onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'left')
|
|
65
65
|
}, /*#__PURE__*/React.createElement("i", {
|
|
66
66
|
className: "sdocfont sdoc-align-left mr-2"
|
|
67
|
-
}), t('Left')), /*#__PURE__*/React.createElement("
|
|
68
|
-
className: "dropdown-item",
|
|
67
|
+
}), t('Left')), /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "sdoc-dropdown-menu-item",
|
|
69
69
|
onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'center')
|
|
70
70
|
}, /*#__PURE__*/React.createElement("i", {
|
|
71
71
|
className: "sdocfont sdoc-align-center mr-2"
|
|
72
|
-
}), t('Center')), /*#__PURE__*/React.createElement("
|
|
73
|
-
className: "dropdown-item",
|
|
72
|
+
}), t('Center')), /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: "sdoc-dropdown-menu-item",
|
|
74
74
|
onClick: _this.setTextAlignStyle.bind(_assertThisInitialized(_this), 'right')
|
|
75
75
|
}, /*#__PURE__*/React.createElement("i", {
|
|
76
76
|
className: "sdocfont sdoc-align-right mr-2"
|
|
@@ -84,11 +84,11 @@ var ActiveTableMenu = /*#__PURE__*/function (_Component) {
|
|
|
84
84
|
ref: function ref(_ref2) {
|
|
85
85
|
return _this.tableColumnRef = _ref2;
|
|
86
86
|
}
|
|
87
|
-
}, /*#__PURE__*/React.createElement("
|
|
88
|
-
className: "dropdown-item",
|
|
87
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: "sdoc-dropdown-menu-item",
|
|
89
89
|
onClick: _this.insertTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.COLUMN)
|
|
90
|
-
}, t('Insert_column')), /*#__PURE__*/React.createElement("
|
|
91
|
-
className: "dropdown-item",
|
|
90
|
+
}, t('Insert_column')), /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
className: "sdoc-dropdown-menu-item",
|
|
92
92
|
onClick: _this.removeTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.COLUMN)
|
|
93
93
|
}, t('Remove_column')));
|
|
94
94
|
};
|
|
@@ -100,11 +100,11 @@ var ActiveTableMenu = /*#__PURE__*/function (_Component) {
|
|
|
100
100
|
ref: function ref(_ref3) {
|
|
101
101
|
return _this.tableRowRef = _ref3;
|
|
102
102
|
}
|
|
103
|
-
}, /*#__PURE__*/React.createElement("
|
|
104
|
-
className: "dropdown-item",
|
|
103
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
104
|
+
className: "sdoc-dropdown-menu-item",
|
|
105
105
|
onClick: _this.insertTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.ROW)
|
|
106
|
-
}, t('Insert_row')), /*#__PURE__*/React.createElement("
|
|
107
|
-
className: "dropdown-item",
|
|
106
|
+
}, t('Insert_row')), /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: "sdoc-dropdown-menu-item",
|
|
108
108
|
onClick: _this.removeTableElement.bind(_assertThisInitialized(_this), TABLE_ELEMENT.ROW)
|
|
109
109
|
}, t('Remove_row')));
|
|
110
110
|
};
|
package/dist/basic-sdk/extension/plugins/table/render/table-header/rows-header/row-header.js
CHANGED
|
@@ -8,6 +8,7 @@ import { useResizeHandlersContext, useTableSelectedRangeContext } from '../../ho
|
|
|
8
8
|
import { useScrollContext } from '../../../../../../hooks/use-scroll-context';
|
|
9
9
|
import { ELEMENT_TYPE } from '../../../../../constants';
|
|
10
10
|
import { findPath, getSelectedNodeByType } from '../../../../../core';
|
|
11
|
+
import { rowElementHasImage } from '../../../helpers';
|
|
11
12
|
var RowHeader = function RowHeader(_ref) {
|
|
12
13
|
var _row$style;
|
|
13
14
|
var row = _ref.row,
|
|
@@ -30,6 +31,18 @@ var RowHeader = function RowHeader(_ref) {
|
|
|
30
31
|
var currentCellPath = currentCell ? findPath(editor, currentCell, [-1, -1]) : [-1, -1];
|
|
31
32
|
var pathLength = currentCellPath.length;
|
|
32
33
|
useEffect(function () {
|
|
34
|
+
if (rowElementHasImage(row)) {
|
|
35
|
+
var time = setTimeout(function () {
|
|
36
|
+
// There is a delay in image loading
|
|
37
|
+
var rowDom = ReactEditor.toDOMNode(editor, row);
|
|
38
|
+
if (!rowDom) return;
|
|
39
|
+
if (rowHeight === rowDom.clientHeight) return;
|
|
40
|
+
setRowHeight(rowDom.clientHeight);
|
|
41
|
+
}, 300);
|
|
42
|
+
return function () {
|
|
43
|
+
clearTimeout(time);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
33
46
|
var rowDom = ReactEditor.toDOMNode(editor, row);
|
|
34
47
|
if (!rowDom) return;
|
|
35
48
|
if (rowHeight === rowDom.clientHeight) return;
|
|
@@ -16,12 +16,15 @@ var TextAlignMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
16
16
|
_classCallCheck(this, TextAlignMenu);
|
|
17
17
|
_this = _super.call(this, props);
|
|
18
18
|
_this.registerEventHandler = function () {
|
|
19
|
-
document.addEventListener('click', _this.onHideTextAlignMenu);
|
|
19
|
+
document.addEventListener('click', _this.onHideTextAlignMenu, true);
|
|
20
20
|
};
|
|
21
21
|
_this.unregisterEventHandler = function () {
|
|
22
|
-
document.removeEventListener('click', _this.onHideTextAlignMenu);
|
|
22
|
+
document.removeEventListener('click', _this.onHideTextAlignMenu, true);
|
|
23
23
|
};
|
|
24
|
-
_this.onHideTextAlignMenu = function () {
|
|
24
|
+
_this.onHideTextAlignMenu = function (e) {
|
|
25
|
+
var menu = _this.menu;
|
|
26
|
+
var clickIsInMenu = menu && menu.contains(e.target) && menu !== e.target;
|
|
27
|
+
if (clickIsInMenu) return;
|
|
25
28
|
_this.setState({
|
|
26
29
|
isDropdownMenuOpen: false
|
|
27
30
|
}, function () {
|
|
@@ -60,6 +63,14 @@ var TextAlignMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
60
63
|
_this.setType = function (type) {
|
|
61
64
|
var editor = _this.props.editor;
|
|
62
65
|
setAlignType(editor, type);
|
|
66
|
+
_this.setState({
|
|
67
|
+
isDropdownMenuOpen: false
|
|
68
|
+
}, function () {
|
|
69
|
+
_this.unregisterEventHandler();
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
_this.setMenuRef = function (ref) {
|
|
73
|
+
_this.menu = ref;
|
|
63
74
|
};
|
|
64
75
|
_this.state = {
|
|
65
76
|
isDropdownMenuOpen: false
|
|
@@ -89,11 +100,12 @@ var TextAlignMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
89
100
|
}), !disabled && /*#__PURE__*/React.createElement("span", {
|
|
90
101
|
className: caretIconClass
|
|
91
102
|
})), isDropdownMenuOpen && /*#__PURE__*/React.createElement("div", {
|
|
92
|
-
|
|
103
|
+
ref: this.setMenuRef,
|
|
104
|
+
className: "align-popover sdoc-dropdown-menu"
|
|
93
105
|
}, MENUS_CONFIG_MAP[TEXT_ALIGN].map(function (item, index) {
|
|
94
106
|
return /*#__PURE__*/React.createElement("span", {
|
|
95
107
|
key: index,
|
|
96
|
-
className: "
|
|
108
|
+
className: "sdoc-dropdown-menu-item ".concat(item.iconClass),
|
|
97
109
|
onClick: _this2.setType.bind(_this2, item.type)
|
|
98
110
|
});
|
|
99
111
|
})));
|
|
@@ -51,15 +51,3 @@
|
|
|
51
51
|
align-items: flex-start;
|
|
52
52
|
z-index: 10;
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
.align-menu .align-popover .align-menu-item {
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
height: 30px;
|
|
58
|
-
width: 100%;
|
|
59
|
-
padding: 4px 24px;
|
|
60
|
-
user-select: none;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.align-menu .align-popover .align-menu-item:hover {
|
|
64
|
-
background-color: rgb(245, 245, 245);
|
|
65
|
-
}
|
|
@@ -210,4 +210,7 @@ SocketManager.getInstance = function (editor, document, socketConfig) {
|
|
|
210
210
|
SocketManager.instance = new SocketManager(editor, document, socketConfig);
|
|
211
211
|
return SocketManager.instance;
|
|
212
212
|
};
|
|
213
|
+
SocketManager.destroy = function () {
|
|
214
|
+
SocketManager.instance = null;
|
|
215
|
+
};
|
|
213
216
|
export default SocketManager;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _this = this;
|
|
2
1
|
import { generateCursorData } from '../cursor/helper';
|
|
3
2
|
import EventBus from '../utils/event-bus';
|
|
4
3
|
import SocketManager from './socket-manager';
|
|
@@ -16,7 +15,8 @@ var withSocketIO = function withSocketIO(editor, options) {
|
|
|
16
15
|
socketManager = SocketManager.getInstance(newEditor, document, config);
|
|
17
16
|
};
|
|
18
17
|
newEditor.closeConnection = function () {
|
|
19
|
-
socketManager &&
|
|
18
|
+
socketManager && socketManager.closeSocketConnect();
|
|
19
|
+
SocketManager.destroy();
|
|
20
20
|
};
|
|
21
21
|
newEditor.onChange = function () {
|
|
22
22
|
var operations = newEditor.operations;
|