@seafile/sdoc-editor 1.0.66-beta1 → 1.0.66-beta2
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/comment/components/global-comment/index.css +2 -7
- package/dist/basic-sdk/comment/components/global-comment/index.js +9 -96
- package/dist/basic-sdk/comment/hooks/comment-hooks/use-comment-list.js +3 -2
- package/dist/basic-sdk/constants/index.js +0 -1
- package/dist/basic-sdk/editor/sdoc-editor.js +4 -6
- package/dist/basic-sdk/layout/editor-content.js +15 -29
- package/dist/basic-sdk/right-panel/index.css +14 -0
- package/dist/basic-sdk/right-panel/index.js +79 -0
- package/dist/basic-sdk/right-panel/resize-width/index.css +38 -0
- package/dist/basic-sdk/right-panel/resize-width/index.js +134 -0
- package/dist/components/doc-operations/index.js +1 -2
- package/dist/components/doc-operations/plugins-operations.js +7 -7
- package/dist/hooks/use-plugins.js +32 -15
- package/dist/pages/simple-editor.js +4 -3
- package/package.json +1 -1
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
.sdoc-comment-drawer {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
min-width: 360px;
|
|
5
|
-
max-width: 620px;
|
|
6
|
-
border-left: 1px solid #e2e3e6;
|
|
7
|
-
/* Prevent the image menu from still appearing above the comment drawer when scrolled hidden. */
|
|
8
|
-
z-index: 102;
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
9
4
|
}
|
|
10
5
|
|
|
11
6
|
.sdoc-comment-drawer .comments-panel-wrapper {
|
|
@@ -20,96 +20,34 @@ var _globalCommentEditor = _interopRequireDefault(require("./global-comment-edit
|
|
|
20
20
|
var _constants2 = require("../../../constants");
|
|
21
21
|
var _core = require("../../../extension/core");
|
|
22
22
|
require("./index.css");
|
|
23
|
+
var _hooks = require("../../../../hooks");
|
|
23
24
|
const GlobalComment = _ref => {
|
|
24
25
|
let {
|
|
25
26
|
deleteUnseenNotifications,
|
|
26
27
|
editor
|
|
27
28
|
} = _ref;
|
|
28
29
|
const [activeComment, setActiveComment] = (0, _react.useState)(null);
|
|
29
|
-
const [isShowCommentList, setShowCommentList] = (0, _react.useState)(false);
|
|
30
30
|
const [showEditor, setShowEditor] = (0, _react.useState)(false);
|
|
31
|
-
const [draggerStyle, setDraggerStyle] = (0, _react.useState)({});
|
|
32
31
|
const [isScrollDisplayed, setIsScrollDisplayed] = (0, _react.useState)(false);
|
|
33
32
|
const commentRef = (0, _react.useRef)(null);
|
|
34
33
|
const contentRef = (0, _react.useRef)(null);
|
|
35
|
-
const commentDrawerRef = (0, _react.useRef)(null);
|
|
36
|
-
const isResizingRef = (0, _react.useRef)(false);
|
|
37
|
-
const commentResizeHandler = (0, _react.useRef)(null);
|
|
38
34
|
const {
|
|
39
35
|
commentList,
|
|
40
36
|
commentType,
|
|
41
37
|
setCommentType
|
|
42
38
|
} = (0, _useCommentList.default)();
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
scrollIntoArticle: true
|
|
47
|
-
});
|
|
48
|
-
}, []);
|
|
49
|
-
(0, _react.useEffect)(() => {
|
|
50
|
-
if (isShowCommentList) {
|
|
51
|
-
setArticleContainerStyle();
|
|
52
|
-
}
|
|
53
|
-
}, [isShowCommentList, setArticleContainerStyle]);
|
|
54
|
-
const toggle = (0, _react.useCallback)(() => {
|
|
55
|
-
if (isShowCommentList) {
|
|
56
|
-
setActiveComment(null);
|
|
57
|
-
setShowCommentList(false);
|
|
58
|
-
setShowEditor(false);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
setShowCommentList(true);
|
|
62
|
-
}, [isShowCommentList]);
|
|
63
|
-
const handleHideDragger = (0, _react.useCallback)(event => {
|
|
64
|
-
if (isResizingRef.current) return;
|
|
65
|
-
setDraggerStyle({
|
|
66
|
-
display: 'none'
|
|
67
|
-
});
|
|
68
|
-
}, []);
|
|
69
|
-
const handleResizeEnd = (0, _react.useCallback)(e => {
|
|
70
|
-
isResizingRef.current = false;
|
|
71
|
-
document.removeEventListener('mouseup', handleResizeEnd);
|
|
72
|
-
handleHideDragger();
|
|
73
|
-
}, [handleHideDragger]);
|
|
39
|
+
const {
|
|
40
|
+
closePlugin
|
|
41
|
+
} = (0, _hooks.usePlugins)();
|
|
74
42
|
const detectScroll = (0, _react.useCallback)(() => {
|
|
75
43
|
if (!contentRef.current) return;
|
|
76
44
|
const contentContainer = contentRef.current;
|
|
77
45
|
const isShowScroll = contentContainer.scrollHeight > contentContainer.clientHeight;
|
|
78
46
|
setIsScrollDisplayed(isShowScroll);
|
|
79
47
|
}, []);
|
|
80
|
-
const handleResizing = (0, _react.useCallback)(e => {
|
|
81
|
-
const commentDrawer = commentDrawerRef.current;
|
|
82
|
-
if (isResizingRef.current && commentDrawer) {
|
|
83
|
-
let width = commentDrawer.offsetWidth - e.movementX;
|
|
84
|
-
// Limit the width of the comment drawer
|
|
85
|
-
width = Math.min(width, 620);
|
|
86
|
-
width = Math.max(width, 360);
|
|
87
|
-
commentDrawer.style.width = `${width}px`;
|
|
88
|
-
const isShrink = e.movementX > 0;
|
|
89
|
-
setArticleContainerStyle({
|
|
90
|
-
width,
|
|
91
|
-
isShrink
|
|
92
|
-
});
|
|
93
|
-
detectScroll();
|
|
94
|
-
}
|
|
95
|
-
}, [detectScroll, setArticleContainerStyle]);
|
|
96
|
-
const handleResizeStart = (0, _react.useCallback)(e => {
|
|
97
|
-
isResizingRef.current = true;
|
|
98
|
-
document.addEventListener('mouseup', handleResizeEnd);
|
|
99
|
-
document.addEventListener('mousemove', handleResizing);
|
|
100
|
-
}, [handleResizeEnd, handleResizing]);
|
|
101
|
-
(0, _react.useEffect)(() => {
|
|
102
|
-
const eventBus = _eventBus.default.getInstance();
|
|
103
|
-
const unsubscribe = eventBus.subscribe(_constants2.INTERNAL_EVENT.COMMENT_LIST_CLICK, toggle);
|
|
104
|
-
return () => {
|
|
105
|
-
unsubscribe();
|
|
106
|
-
document.removeEventListener('mousemove', handleResizing);
|
|
107
|
-
eventBus.dispatch(_constants2.INTERNAL_EVENT.OUTLINE_STATE_CHANGED);
|
|
108
|
-
};
|
|
109
|
-
}, [handleResizing, toggle]);
|
|
110
48
|
(0, _react.useEffect)(() => {
|
|
111
49
|
detectScroll();
|
|
112
|
-
}, [commentList, detectScroll
|
|
50
|
+
}, [commentList, detectScroll]);
|
|
113
51
|
const updateScrollPosition = (0, _react.useCallback)(() => {
|
|
114
52
|
const resolvedDom = document.querySelector('.sdoc-resolved');
|
|
115
53
|
contentRef.current.scrollTo({
|
|
@@ -174,44 +112,18 @@ const GlobalComment = _ref => {
|
|
|
174
112
|
const hiddenCommentEditor = (0, _react.useCallback)(() => {
|
|
175
113
|
setShowEditor(false);
|
|
176
114
|
}, []);
|
|
177
|
-
const handleDisplayDragger = (0, _react.useCallback)(event => {
|
|
178
|
-
if (isShowCommentList) {
|
|
179
|
-
const {
|
|
180
|
-
pageY
|
|
181
|
-
} = event;
|
|
182
|
-
const {
|
|
183
|
-
top
|
|
184
|
-
} = commentResizeHandler.current.getBoundingClientRect();
|
|
185
|
-
// 15 is the half height of the dragger
|
|
186
|
-
const topSize = pageY - top - 15;
|
|
187
|
-
setDraggerStyle({
|
|
188
|
-
top: `${topSize}px`,
|
|
189
|
-
display: 'block'
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}, [isShowCommentList]);
|
|
193
115
|
const isClickCommentPanelBody = (0, _react.useCallback)(event => {
|
|
194
116
|
if (contentRef.current && contentRef.current.contains(event.target)) return true;
|
|
195
117
|
return false;
|
|
196
118
|
}, []);
|
|
197
|
-
|
|
119
|
+
console.log(commentList);
|
|
198
120
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
199
|
-
className: "sdoc-comment-drawer"
|
|
200
|
-
ref: commentDrawerRef
|
|
201
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
202
|
-
ref: commentResizeHandler,
|
|
203
|
-
className: "sdoc-comment-resize-handler",
|
|
204
|
-
onMouseDown: handleResizeStart,
|
|
205
|
-
onMouseLeave: handleHideDragger,
|
|
206
|
-
onMouseMove: handleDisplayDragger
|
|
121
|
+
className: "sdoc-comment-drawer"
|
|
207
122
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
208
|
-
style: draggerStyle,
|
|
209
|
-
className: "sdoc-comment-move-dragger"
|
|
210
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
211
123
|
ref: commentRef,
|
|
212
124
|
className: "comments-panel-wrapper"
|
|
213
125
|
}, /*#__PURE__*/_react.default.createElement(_globalCommentHeader.default, {
|
|
214
|
-
toggle:
|
|
126
|
+
toggle: closePlugin,
|
|
215
127
|
toggleGlobalCommentEditor: toggleGlobalCommentEditor
|
|
216
128
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
217
129
|
className: "comments-panel-body"
|
|
@@ -226,6 +138,7 @@ const GlobalComment = _ref => {
|
|
|
226
138
|
id: "global-comment-list-container",
|
|
227
139
|
className: "sdoc-comment-list-container"
|
|
228
140
|
}, Array.isArray(commentList) && commentList.map(comment => {
|
|
141
|
+
console.log(comment);
|
|
229
142
|
const elementId = comment.detail.element_id;
|
|
230
143
|
const element = elementId !== _constants.DOC_COMMENT_ELEMENT_ID ? (0, _core.getNodeById)(editor.children, elementId) : null;
|
|
231
144
|
const isActive = activeComment && activeComment.id === comment.id;
|
|
@@ -13,9 +13,10 @@ const useCommentList = () => {
|
|
|
13
13
|
} = (0, _useCommentContext.useCommentContext)();
|
|
14
14
|
const {
|
|
15
15
|
comment_list
|
|
16
|
-
} = commentsInfo ||
|
|
16
|
+
} = commentsInfo || {};
|
|
17
|
+
console.log(comment_list);
|
|
17
18
|
const [commentType, setCommentType] = (0, _react.useState)(_constants.COMMENT_TYPES.ALL);
|
|
18
|
-
const [commentList, setCommentList] = (0, _react.useState)([
|
|
19
|
+
const [commentList, setCommentList] = (0, _react.useState)([]);
|
|
19
20
|
(0, _react.useEffect)(() => {
|
|
20
21
|
if (commentType === _constants.COMMENT_TYPES.ALL) {
|
|
21
22
|
setCommentList(comment_list);
|
|
@@ -33,7 +33,6 @@ const INTERNAL_EVENT = exports.INTERNAL_EVENT = {
|
|
|
33
33
|
OUTLINE_STATE_CHANGED: 'outline_state_changed',
|
|
34
34
|
RELOAD_IMAGE: 'reload_image',
|
|
35
35
|
ARTICLE_CLICK: 'hidden_comment',
|
|
36
|
-
COMMENT_LIST_CLICK: 'comment_list_click',
|
|
37
36
|
UNSEEN_NOTIFICATIONS_COUNT: 'unseen_notifications_count',
|
|
38
37
|
CLOSE_CALLOUT_COLOR_PICKER: 'close_callout_color_picker',
|
|
39
38
|
OPEN_SEARCH_REPLACE_MODAL: 'open_search_replace_modal',
|
|
@@ -22,7 +22,6 @@ var _editableArticle = _interopRequireDefault(require("./editable-article"));
|
|
|
22
22
|
var _useColorContext = require("../hooks/use-color-context");
|
|
23
23
|
var _readonlyArticle = _interopRequireDefault(require("../views/readonly-article"));
|
|
24
24
|
var _utils = require("../../utils");
|
|
25
|
-
var _hooks = require("../../hooks");
|
|
26
25
|
var _basicSdk = require("../../basic-sdk");
|
|
27
26
|
var _constants2 = require("../../constants");
|
|
28
27
|
const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
@@ -159,7 +158,7 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
159
158
|
return /*#__PURE__*/_react.default.createElement(_layout.EditorContainer, {
|
|
160
159
|
editor: validEditor,
|
|
161
160
|
readonly: isFreezed
|
|
162
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
161
|
+
}, /*#__PURE__*/_react.default.createElement(_useColorContext.ColorProvider, null, isShowHeaderToolbar && /*#__PURE__*/_react.default.createElement(_extension.HeaderToolbar, {
|
|
163
162
|
editor: validEditor,
|
|
164
163
|
readonly: isFreezed
|
|
165
164
|
}), /*#__PURE__*/_react.default.createElement(_layout.EditorContent, {
|
|
@@ -172,13 +171,12 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
172
171
|
editor: validEditor,
|
|
173
172
|
slateValue: slateValue,
|
|
174
173
|
showComment: true
|
|
175
|
-
}))))
|
|
174
|
+
}))));
|
|
176
175
|
}
|
|
177
176
|
const isShowComment = typeof showComment === 'boolean' ? showComment : true;
|
|
178
|
-
const Provider = isShowComment ? _hooks.CollaboratorsProvider : _react.Fragment;
|
|
179
177
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_layout.EditorContainer, {
|
|
180
178
|
editor: validEditor
|
|
181
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
179
|
+
}, /*#__PURE__*/_react.default.createElement(_useColorContext.ColorProvider, null, isShowHeaderToolbar && /*#__PURE__*/_react.default.createElement(_extension.HeaderToolbar, {
|
|
182
180
|
editor: validEditor
|
|
183
181
|
}), /*#__PURE__*/_react.default.createElement(_layout.EditorContent, {
|
|
184
182
|
docValue: slateValue,
|
|
@@ -190,7 +188,7 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
190
188
|
slateValue: slateValue,
|
|
191
189
|
updateSlateValue: onValueChange,
|
|
192
190
|
showComment: isShowComment
|
|
193
|
-
}))))
|
|
191
|
+
})))), /*#__PURE__*/_react.default.createElement(_insertElementDialog.default, {
|
|
194
192
|
editor: validEditor
|
|
195
193
|
}));
|
|
196
194
|
});
|
|
@@ -10,9 +10,9 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _useScrollContext = require("../hooks/use-scroll-context");
|
|
11
11
|
var _outline = _interopRequireDefault(require("../outline"));
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
var _comment = _interopRequireDefault(require("../comment"));
|
|
14
13
|
var _provider = _interopRequireDefault(require("../comment/provider"));
|
|
15
14
|
var _useParticipants = require("../comment/hooks/use-participants");
|
|
15
|
+
var _rightPanel = _interopRequireDefault(require("../right-panel"));
|
|
16
16
|
const EditorContent = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
readonly,
|
|
@@ -34,30 +34,7 @@ const EditorContent = _ref => {
|
|
|
34
34
|
'readonly': readonly,
|
|
35
35
|
'no-outline': !showOutline
|
|
36
36
|
});
|
|
37
|
-
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
39
|
-
className: "sdoc-content-wrapper"
|
|
40
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
41
|
-
ref: scrollRef,
|
|
42
|
-
className: "sdoc-scroll-container",
|
|
43
|
-
onScroll: onWrapperScroll,
|
|
44
|
-
id: "sdoc-scroll-container"
|
|
45
|
-
}, /*#__PURE__*/_react.default.createElement(_useScrollContext.ScrollContext.Provider, {
|
|
46
|
-
value: {
|
|
47
|
-
scrollRef
|
|
48
|
-
}
|
|
49
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
50
|
-
className: className
|
|
51
|
-
}, showOutline && /*#__PURE__*/_react.default.createElement(_outline.default, {
|
|
52
|
-
scrollLeft: scrollLeft,
|
|
53
|
-
doc: docValue
|
|
54
|
-
}), children))));
|
|
55
|
-
}
|
|
56
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
-
className: "sdoc-content-wrapper"
|
|
58
|
-
}, /*#__PURE__*/_react.default.createElement(_provider.default, {
|
|
59
|
-
editor: editor
|
|
60
|
-
}, /*#__PURE__*/_react.default.createElement(_useParticipants.ParticipantsProvider, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
37
|
+
const dom = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
61
38
|
ref: scrollRef,
|
|
62
39
|
className: "sdoc-scroll-container",
|
|
63
40
|
onScroll: onWrapperScroll,
|
|
@@ -71,10 +48,19 @@ const EditorContent = _ref => {
|
|
|
71
48
|
}, showOutline && /*#__PURE__*/_react.default.createElement(_outline.default, {
|
|
72
49
|
scrollLeft: scrollLeft,
|
|
73
50
|
doc: docValue
|
|
74
|
-
}), children))), /*#__PURE__*/_react.default.createElement(
|
|
75
|
-
editor: editor
|
|
76
|
-
|
|
77
|
-
|
|
51
|
+
}), children))), /*#__PURE__*/_react.default.createElement(_rightPanel.default, {
|
|
52
|
+
editor: editor
|
|
53
|
+
}));
|
|
54
|
+
if (!showComment) {
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
56
|
+
className: "sdoc-content-wrapper"
|
|
57
|
+
}, dom);
|
|
58
|
+
}
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
60
|
+
className: "sdoc-content-wrapper"
|
|
61
|
+
}, /*#__PURE__*/_react.default.createElement(_provider.default, {
|
|
62
|
+
editor: editor
|
|
63
|
+
}, /*#__PURE__*/_react.default.createElement(_useParticipants.ParticipantsProvider, null, dom)));
|
|
78
64
|
};
|
|
79
65
|
EditorContent.defaultProps = {
|
|
80
66
|
readonly: false,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.sdoc-content-right-panel-wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
max-width: 620px;
|
|
5
|
+
min-width: 360px;
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sdoc-content-right-panel-wrapper .sdoc-content-right-panel {
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
border-left: 1px solid #d8d8d8;
|
|
14
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _hooks = require("../../hooks");
|
|
11
|
+
var _resizeWidth = _interopRequireDefault(require("./resize-width"));
|
|
12
|
+
var _comment = _interopRequireDefault(require("../comment"));
|
|
13
|
+
require("./index.css");
|
|
14
|
+
const MIN_PANEL_WIDTH = 360;
|
|
15
|
+
const MAX_PANEL_WIDTH = 620;
|
|
16
|
+
const RightPanel = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
editor
|
|
19
|
+
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
plugins,
|
|
22
|
+
displayPluginName
|
|
23
|
+
} = (0, _hooks.usePlugins)();
|
|
24
|
+
const panelWrapperRef = (0, _react.useRef)(null);
|
|
25
|
+
const {
|
|
26
|
+
collaborators
|
|
27
|
+
} = (0, _hooks.useCollaborators)();
|
|
28
|
+
const panelWrapperStyle = (0, _react.useMemo)(() => {
|
|
29
|
+
if (!displayPluginName) return null;
|
|
30
|
+
const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}')) || {};
|
|
31
|
+
console.log(panelWidth);
|
|
32
|
+
const width = panelWidth[displayPluginName] || MIN_PANEL_WIDTH;
|
|
33
|
+
let style = {
|
|
34
|
+
width,
|
|
35
|
+
zIndex: 101
|
|
36
|
+
};
|
|
37
|
+
if (!style.width || style.width < MIN_PANEL_WIDTH) {
|
|
38
|
+
style.width = MIN_PANEL_WIDTH;
|
|
39
|
+
} else if (style.width > MAX_PANEL_WIDTH) {
|
|
40
|
+
style.width = MAX_PANEL_WIDTH;
|
|
41
|
+
}
|
|
42
|
+
return style;
|
|
43
|
+
}, [displayPluginName]);
|
|
44
|
+
const resizeWidth = (0, _react.useCallback)(width => {
|
|
45
|
+
if (panelWrapperRef.current) {
|
|
46
|
+
panelWrapperRef.current.style.width = `${width}px`;
|
|
47
|
+
}
|
|
48
|
+
}, [panelWrapperRef]);
|
|
49
|
+
const resizeWidthEnd = (0, _react.useCallback)(width => {
|
|
50
|
+
const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}'));
|
|
51
|
+
window.localStorage.setItem('sdoc-panel-width', JSON.stringify({
|
|
52
|
+
...panelWidth,
|
|
53
|
+
[displayPluginName]: width
|
|
54
|
+
}));
|
|
55
|
+
}, [displayPluginName]);
|
|
56
|
+
if (!displayPluginName) return null;
|
|
57
|
+
const plugin = plugins.find(p => p.name === displayPluginName);
|
|
58
|
+
if (!plugin) return null;
|
|
59
|
+
const Component = plugin.Component;
|
|
60
|
+
if (!Component) return null;
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
62
|
+
className: "sdoc-content-right-panel-wrapper",
|
|
63
|
+
ref: panelWrapperRef,
|
|
64
|
+
style: panelWrapperStyle
|
|
65
|
+
}, plugin.resizable_width && /*#__PURE__*/_react.default.createElement(_resizeWidth.default, {
|
|
66
|
+
minWidth: MIN_PANEL_WIDTH,
|
|
67
|
+
maxWidth: MAX_PANEL_WIDTH,
|
|
68
|
+
resizeWidth: resizeWidth,
|
|
69
|
+
resizeWidthEnd: resizeWidthEnd
|
|
70
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
+
className: "sdoc-content-right-panel",
|
|
72
|
+
id: "sdoc-content-right-panel"
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement(Component, {
|
|
74
|
+
editor: editor,
|
|
75
|
+
type: "global",
|
|
76
|
+
collaborators: collaborators
|
|
77
|
+
})));
|
|
78
|
+
};
|
|
79
|
+
var _default = exports.default = RightPanel;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.sdoc-resize-width-handler {
|
|
2
|
+
height: 100%;
|
|
3
|
+
position: absolute;
|
|
4
|
+
right: 0;
|
|
5
|
+
top: 0;
|
|
6
|
+
width: 6px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.sdoc-resize-width-handler.resize-handler-placement-right {
|
|
10
|
+
left: 0;
|
|
11
|
+
right: auto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sdoc-resize-width-handler:hover {
|
|
15
|
+
cursor: col-resize;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.sdoc-resize-width-handler .sdoc-resize-width-handler-content {
|
|
19
|
+
background-color: initial;
|
|
20
|
+
height: 100%;
|
|
21
|
+
position: relative;
|
|
22
|
+
width: 2px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.sdoc-resize-width-handler:hover .sdoc-resize-width-handler-content {
|
|
26
|
+
background-color: #ccc;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.sdoc-resize-width-handler .sdoc-resize-width-handler-bar {
|
|
30
|
+
background-color: #2d7ff9;
|
|
31
|
+
border-radius: 3px;
|
|
32
|
+
content: "";
|
|
33
|
+
left: 50%;
|
|
34
|
+
margin-left: -3px;
|
|
35
|
+
position: absolute;
|
|
36
|
+
width: 6px;
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
require("./index.css");
|
|
12
|
+
const ResizeWidth = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
minWidth,
|
|
15
|
+
maxWidth,
|
|
16
|
+
resizeWidth: resizeWidthAPI,
|
|
17
|
+
resizeWidthEnd
|
|
18
|
+
} = _ref;
|
|
19
|
+
const [isShowHandlerBar, setIsShowHandlerBar] = (0, _react.useState)(false);
|
|
20
|
+
const [drag, setDrag] = (0, _react.useState)(null);
|
|
21
|
+
const handlerRef = (0, _react.useRef)(null);
|
|
22
|
+
const handlerBarRef = (0, _react.useRef)(null);
|
|
23
|
+
const setHandlerBarTop = handlerTop => {
|
|
24
|
+
if (!handlerBarRef.current || handlerTop < 0) return;
|
|
25
|
+
handlerBarRef.current.style.top = handlerTop + 'px';
|
|
26
|
+
};
|
|
27
|
+
const setHandlerBarPosition = event => {
|
|
28
|
+
if (!handlerRef.current) return;
|
|
29
|
+
const {
|
|
30
|
+
top
|
|
31
|
+
} = handlerRef.current.getBoundingClientRect();
|
|
32
|
+
const handlerTop = event.pageY - top - 26 / 2;
|
|
33
|
+
setHandlerBarTop(handlerTop);
|
|
34
|
+
};
|
|
35
|
+
const getWidthFromMouseEvent = event => {
|
|
36
|
+
return event.pageX || event.touches && event.touches[0] && event.touches[0].pageX || event.changedTouches && event.changedTouches[event.changedTouches.length - 1].pageX;
|
|
37
|
+
};
|
|
38
|
+
const calculateResizedWidth = event => {
|
|
39
|
+
const width = getWidthFromMouseEvent(event);
|
|
40
|
+
const resizedWidth = document.body.clientWidth - width;
|
|
41
|
+
if (minWidth && resizedWidth < minWidth || maxWidth && resizedWidth > maxWidth) return -1;
|
|
42
|
+
return resizedWidth;
|
|
43
|
+
};
|
|
44
|
+
const onResizeWidth = event => {
|
|
45
|
+
const resizedWidth = calculateResizedWidth(event);
|
|
46
|
+
if (resizedWidth < 0) return;
|
|
47
|
+
if (resizeWidthAPI) {
|
|
48
|
+
resizeWidthAPI(resizedWidth);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const onDrag = event => {
|
|
52
|
+
onResizeWidth(event);
|
|
53
|
+
};
|
|
54
|
+
const onDragStart = (0, _react.useCallback)(event => {
|
|
55
|
+
if (event && event.dataTransfer && event.dataTransfer.setData) {
|
|
56
|
+
event.dataTransfer.setData('text/plain', 'dummy');
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
59
|
+
const onDragEnd = event => {
|
|
60
|
+
onResizeWidth(event);
|
|
61
|
+
};
|
|
62
|
+
const onMouseLeave = () => {
|
|
63
|
+
setIsShowHandlerBar(false);
|
|
64
|
+
};
|
|
65
|
+
const onMouseEnter = event => {
|
|
66
|
+
setIsShowHandlerBar(true);
|
|
67
|
+
setHandlerBarPosition(event);
|
|
68
|
+
if (handlerRef.current) {
|
|
69
|
+
handlerRef.current.addEventListener('mouseleave', onMouseLeave);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const onMouseOver = (0, _react.useCallback)(event => {
|
|
73
|
+
setHandlerBarPosition(event);
|
|
74
|
+
}, [setHandlerBarPosition]);
|
|
75
|
+
const onMouseDown = event => {
|
|
76
|
+
event.preventDefault && event.preventDefault();
|
|
77
|
+
const currDrag = onDragStart(event);
|
|
78
|
+
if (currDrag === null && event.button !== 0) return;
|
|
79
|
+
window.addEventListener('mouseup', onMouseUp);
|
|
80
|
+
window.addEventListener('mousemove', onMouseMove);
|
|
81
|
+
if (handlerRef.current) {
|
|
82
|
+
handlerRef.current.removeEventListener('mouseleave', onMouseLeave);
|
|
83
|
+
}
|
|
84
|
+
setDrag(currDrag);
|
|
85
|
+
};
|
|
86
|
+
const onMouseMove = event => {
|
|
87
|
+
event.preventDefault && event.preventDefault();
|
|
88
|
+
if (!drag === null) return;
|
|
89
|
+
onDrag(event);
|
|
90
|
+
};
|
|
91
|
+
const onMouseUp = event => {
|
|
92
|
+
window.removeEventListener('mouseup', onMouseUp);
|
|
93
|
+
window.removeEventListener('mousemove', onMouseMove);
|
|
94
|
+
onDragEnd(event, drag);
|
|
95
|
+
setHandlerBarTop(-9999);
|
|
96
|
+
setDrag(null);
|
|
97
|
+
setIsShowHandlerBar(false);
|
|
98
|
+
if (resizeWidthEnd) {
|
|
99
|
+
const resizeWidth = calculateResizedWidth(event);
|
|
100
|
+
if (resizeWidth < 0) return;
|
|
101
|
+
resizeWidthEnd(resizeWidth);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
(0, _react.useEffect)(() => {
|
|
105
|
+
return () => {
|
|
106
|
+
window.removeEventListener('mouseup', onMouseUp);
|
|
107
|
+
window.removeEventListener('mousemove', onMouseMove);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// eslint-disable-next-line
|
|
111
|
+
}, []);
|
|
112
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
113
|
+
className: "sdoc-resize-width-handler resize-handler-placement-right",
|
|
114
|
+
ref: handlerRef,
|
|
115
|
+
onMouseDown: onMouseDown,
|
|
116
|
+
onMouseOver: onMouseOver,
|
|
117
|
+
onMouseEnter: onMouseEnter,
|
|
118
|
+
onDrag: onDrag,
|
|
119
|
+
onDragStart: onDragStart,
|
|
120
|
+
onDragEnd: onDragEnd,
|
|
121
|
+
style: {
|
|
122
|
+
zIndex: 4
|
|
123
|
+
}
|
|
124
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
125
|
+
className: "sdoc-resize-width-handler-content"
|
|
126
|
+
}, isShowHandlerBar && /*#__PURE__*/_react.default.createElement("div", {
|
|
127
|
+
className: "sdoc-resize-width-handler-bar",
|
|
128
|
+
ref: handlerBarRef,
|
|
129
|
+
style: {
|
|
130
|
+
height: 26
|
|
131
|
+
}
|
|
132
|
+
})));
|
|
133
|
+
};
|
|
134
|
+
var _default = exports.default = ResizeWidth;
|
|
@@ -11,7 +11,6 @@ var _context = _interopRequireDefault(require("../../context"));
|
|
|
11
11
|
var _revisionOperations = _interopRequireDefault(require("./revision-operations"));
|
|
12
12
|
var _collaboratorsOperation = _interopRequireDefault(require("./collaborators-operation"));
|
|
13
13
|
var _moreOperations = _interopRequireDefault(require("./more-operations"));
|
|
14
|
-
var _commentsOperation = _interopRequireDefault(require("./comments-operation"));
|
|
15
14
|
var _shareOperation = _interopRequireDefault(require("./share-operation"));
|
|
16
15
|
var _pluginsOperations = _interopRequireDefault(require("./plugins-operations"));
|
|
17
16
|
var _utils = require("../../utils");
|
|
@@ -40,6 +39,6 @@ const DocOperations = _ref => {
|
|
|
40
39
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
41
40
|
handleRevisionMerged: handleRevisionMerged,
|
|
42
41
|
handleRevisionPublished: handleRevisionPublished
|
|
43
|
-
}), !isSdocRevision && /*#__PURE__*/_react.default.createElement(_pluginsOperations.default, null), !
|
|
42
|
+
}), !isSdocRevision && /*#__PURE__*/_react.default.createElement(_pluginsOperations.default, null), !isSdocRevision && /*#__PURE__*/_react.default.createElement(_shareOperation.default, null), !isPublished && /*#__PURE__*/_react.default.createElement(_collaboratorsOperation.default, null), !isSdocRevision && /*#__PURE__*/_react.default.createElement(_moreOperations.default, null));
|
|
44
43
|
};
|
|
45
44
|
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(DocOperations);
|
|
@@ -14,15 +14,15 @@ const PluginsOperations = _ref => {
|
|
|
14
14
|
let {} = _ref;
|
|
15
15
|
const {
|
|
16
16
|
plugins,
|
|
17
|
-
|
|
17
|
+
updateDisplayPlugin
|
|
18
18
|
} = (0, _hooks.usePlugins)();
|
|
19
|
-
const onClick = (0, _react.useCallback)((event,
|
|
19
|
+
const onClick = (0, _react.useCallback)((event, pluginName) => {
|
|
20
20
|
(0, _mouseEvent.eventStopPropagation)(event);
|
|
21
|
-
|
|
22
|
-
}, []);
|
|
21
|
+
updateDisplayPlugin(pluginName);
|
|
22
|
+
}, [updateDisplayPlugin]);
|
|
23
23
|
return plugins.map(plugin => {
|
|
24
24
|
const {
|
|
25
|
-
|
|
25
|
+
name,
|
|
26
26
|
icon
|
|
27
27
|
} = plugin;
|
|
28
28
|
let iconDom = '';
|
|
@@ -35,8 +35,8 @@ const PluginsOperations = _ref => {
|
|
|
35
35
|
}
|
|
36
36
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
37
37
|
className: "op-item sdoc-plugin-operation-btn-container",
|
|
38
|
-
onClick: e => onClick(e,
|
|
39
|
-
key:
|
|
38
|
+
onClick: e => onClick(e, name),
|
|
39
|
+
key: name
|
|
40
40
|
}, iconDom);
|
|
41
41
|
});
|
|
42
42
|
};
|
|
@@ -1,38 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.usePlugins = exports.PluginsProvider = void 0;
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _basicSdk = require("../basic-sdk");
|
|
10
10
|
var _constants = require("../basic-sdk/constants");
|
|
11
|
+
var _comment = _interopRequireDefault(require("../basic-sdk/comment"));
|
|
11
12
|
const PluginsContext = /*#__PURE__*/_react.default.createContext(null);
|
|
12
13
|
const PluginsProvider = _ref => {
|
|
13
14
|
let {
|
|
14
|
-
|
|
15
|
+
showComment,
|
|
16
|
+
plugins: propsPlugins,
|
|
15
17
|
children
|
|
16
18
|
} = _ref;
|
|
17
|
-
const [
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const [displayName, setDisplayName] = (0, _react.useState)('');
|
|
20
|
+
const closePlugin = (0, _react.useCallback)(() => {
|
|
21
|
+
setDisplayName('');
|
|
22
|
+
}, []);
|
|
23
|
+
const plugins = (0, _react.useMemo)(() => {
|
|
24
|
+
const allPlugins = propsPlugins;
|
|
25
|
+
if (showComment) {
|
|
26
|
+
allPlugins.push({
|
|
27
|
+
name: 'sdoc-comment',
|
|
28
|
+
icon: 'sdoc-comments',
|
|
29
|
+
position: '',
|
|
30
|
+
resizable_width: true,
|
|
31
|
+
display_type: 'inlay-right',
|
|
32
|
+
Component: _comment.default
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return allPlugins;
|
|
36
|
+
}, [showComment, propsPlugins]);
|
|
37
|
+
const updateDisplayPlugin = (0, _react.useCallback)(name => {
|
|
38
|
+
if (!name || displayName === name) {
|
|
39
|
+
setDisplayName('');
|
|
22
40
|
return;
|
|
23
41
|
}
|
|
24
|
-
const plugin = plugins.find(plugin => plugin.
|
|
25
|
-
if (plugin.display_type === _constants.PLUGIN_DISPLAY_TYPE.INLAY_RIGHT) {
|
|
26
|
-
|
|
27
|
-
eventBus.dispatch(_constants.INTERNAL_EVENT.COMMENT_LIST_CLICK);
|
|
28
|
-
setDisplayKey(key);
|
|
42
|
+
const plugin = plugins.find(plugin => plugin.name === name);
|
|
43
|
+
if ((plugin === null || plugin === void 0 ? void 0 : plugin.display_type) === _constants.PLUGIN_DISPLAY_TYPE.INLAY_RIGHT) {
|
|
44
|
+
setDisplayName(name);
|
|
29
45
|
}
|
|
30
|
-
}, [
|
|
46
|
+
}, [displayName, plugins]);
|
|
31
47
|
return /*#__PURE__*/_react.default.createElement(PluginsContext.Provider, {
|
|
32
48
|
value: {
|
|
33
49
|
plugins,
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
displayPluginName: displayName,
|
|
51
|
+
updateDisplayPlugin,
|
|
52
|
+
closePlugin
|
|
36
53
|
}
|
|
37
54
|
}, children);
|
|
38
55
|
};
|
|
@@ -141,8 +141,9 @@ const SimpleEditor = _ref => {
|
|
|
141
141
|
className: "error-tip"
|
|
142
142
|
}, t(errorMessage)));
|
|
143
143
|
}
|
|
144
|
-
return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_hooks.PluginsProvider, {
|
|
145
|
-
plugins: plugins
|
|
144
|
+
return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_hooks.CollaboratorsProvider, null, /*#__PURE__*/_react.default.createElement(_hooks.PluginsProvider, {
|
|
145
|
+
plugins: plugins,
|
|
146
|
+
showComment: showComment
|
|
146
147
|
}, /*#__PURE__*/_react.default.createElement(_layout.default, null, /*#__PURE__*/_react.default.createElement(_layout.Header, null, /*#__PURE__*/_react.default.createElement(_docInfo.default, {
|
|
147
148
|
isStarred: isStarred,
|
|
148
149
|
isDraft: isDraft,
|
|
@@ -156,6 +157,6 @@ const SimpleEditor = _ref => {
|
|
|
156
157
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
157
158
|
handleRevisionMerged: handleRevisionMerged,
|
|
158
159
|
handleRevisionPublished: handleRevisionPublished
|
|
159
|
-
})), /*#__PURE__*/_react.default.createElement(_layout.Content, null, renderEditor()))));
|
|
160
|
+
})), /*#__PURE__*/_react.default.createElement(_layout.Content, null, renderEditor())))));
|
|
160
161
|
};
|
|
161
162
|
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(SimpleEditor);
|