@seafile/sdoc-editor 1.0.66 → 1.0.68
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 +15 -2
- package/dist/basic-sdk/constants/plugin.js +14 -0
- package/dist/basic-sdk/editor/sdoc-editor.js +6 -7
- package/dist/basic-sdk/extension/constants/menus-config.js +7 -0
- package/dist/basic-sdk/extension/plugins/paragraph/plugin/index.js +50 -1
- package/dist/basic-sdk/extension/plugins/sdoc-link/plugin.js +10 -8
- 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 +82 -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 +2 -2
- package/dist/components/doc-operations/plugins-operations.js +42 -0
- package/dist/hooks/index.js +14 -1
- package/dist/hooks/use-collaborators.js +8 -3
- package/dist/hooks/use-plugins.js +64 -0
- package/dist/pages/simple-editor.js +10 -3
- package/package.json +1 -1
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +4 -0
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +14 -6
|
@@ -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);
|
|
@@ -4,9 +4,23 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.PAGE_EDIT_AREA_WIDTH = exports.MODIFY_TYPE = exports.INTERNAL_EVENT = exports.DOCUMENT_PLUGIN_EDITOR = exports.DIFF_VIEWER = exports.COMMENT_EDITOR_EDIT_AREA_WIDTH = exports.COMMENT_EDITOR = void 0;
|
|
8
|
+
Object.defineProperty(exports, "PLUGIN_BTN_POSITION", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _plugin.PLUGIN_BTN_POSITION;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "PLUGIN_DISPLAY_TYPE", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _plugin.PLUGIN_DISPLAY_TYPE;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.Z_INDEX = exports.WIKI_EDITOR = exports.REVISION_DIFF_VALUE = exports.REVISION_DIFF_KEY = exports.REBASE_TYPES = exports.REBASE_TYPE = exports.REBASE_ORIGIN = exports.REBASE_MARK_KEY = exports.REBASE_MARKS = void 0;
|
|
8
21
|
var Z_INDEX = _interopRequireWildcard(require("./z-index"));
|
|
9
22
|
exports.Z_INDEX = Z_INDEX;
|
|
23
|
+
var _plugin = require("./plugin");
|
|
10
24
|
const INTERNAL_EVENT = exports.INTERNAL_EVENT = {
|
|
11
25
|
CANCEL_TABLE_SELECT_RANGE: 'cancel_table_select_range',
|
|
12
26
|
SET_TABLE_SELECT_RANGE: 'set_table_select_range',
|
|
@@ -19,7 +33,6 @@ const INTERNAL_EVENT = exports.INTERNAL_EVENT = {
|
|
|
19
33
|
OUTLINE_STATE_CHANGED: 'outline_state_changed',
|
|
20
34
|
RELOAD_IMAGE: 'reload_image',
|
|
21
35
|
ARTICLE_CLICK: 'hidden_comment',
|
|
22
|
-
COMMENT_LIST_CLICK: 'comment_list_click',
|
|
23
36
|
UNSEEN_NOTIFICATIONS_COUNT: 'unseen_notifications_count',
|
|
24
37
|
CLOSE_CALLOUT_COLOR_PICKER: 'close_callout_color_picker',
|
|
25
38
|
OPEN_SEARCH_REPLACE_MODAL: 'open_search_replace_modal',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PLUGIN_DISPLAY_TYPE = exports.PLUGIN_BTN_POSITION = void 0;
|
|
7
|
+
const PLUGIN_DISPLAY_TYPE = exports.PLUGIN_DISPLAY_TYPE = {
|
|
8
|
+
INLAY_RIGHT: 'inlay-right',
|
|
9
|
+
DIALOG: 'dialog'
|
|
10
|
+
};
|
|
11
|
+
const PLUGIN_BTN_POSITION = exports.PLUGIN_BTN_POSITION = {
|
|
12
|
+
MORE_MENU: 'more-menu',
|
|
13
|
+
DEFAULT: 'default'
|
|
14
|
+
};
|
|
@@ -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) => {
|
|
@@ -32,7 +31,8 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
32
31
|
isReloading,
|
|
33
32
|
showComment,
|
|
34
33
|
isShowHeaderToolbar = true,
|
|
35
|
-
showOutline = true
|
|
34
|
+
showOutline = true,
|
|
35
|
+
plugins = []
|
|
36
36
|
} = _ref;
|
|
37
37
|
const validEditor = (0, _react.useMemo)(() => {
|
|
38
38
|
if (propsEditor) return propsEditor;
|
|
@@ -158,7 +158,7 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
158
158
|
return /*#__PURE__*/_react.default.createElement(_layout.EditorContainer, {
|
|
159
159
|
editor: validEditor,
|
|
160
160
|
readonly: isFreezed
|
|
161
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
161
|
+
}, /*#__PURE__*/_react.default.createElement(_useColorContext.ColorProvider, null, isShowHeaderToolbar && /*#__PURE__*/_react.default.createElement(_extension.HeaderToolbar, {
|
|
162
162
|
editor: validEditor,
|
|
163
163
|
readonly: isFreezed
|
|
164
164
|
}), /*#__PURE__*/_react.default.createElement(_layout.EditorContent, {
|
|
@@ -171,13 +171,12 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
171
171
|
editor: validEditor,
|
|
172
172
|
slateValue: slateValue,
|
|
173
173
|
showComment: true
|
|
174
|
-
}))))
|
|
174
|
+
}))));
|
|
175
175
|
}
|
|
176
176
|
const isShowComment = typeof showComment === 'boolean' ? showComment : true;
|
|
177
|
-
const Provider = isShowComment ? _hooks.CollaboratorsProvider : _react.Fragment;
|
|
178
177
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_layout.EditorContainer, {
|
|
179
178
|
editor: validEditor
|
|
180
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
179
|
+
}, /*#__PURE__*/_react.default.createElement(_useColorContext.ColorProvider, null, isShowHeaderToolbar && /*#__PURE__*/_react.default.createElement(_extension.HeaderToolbar, {
|
|
181
180
|
editor: validEditor
|
|
182
181
|
}), /*#__PURE__*/_react.default.createElement(_layout.EditorContent, {
|
|
183
182
|
docValue: slateValue,
|
|
@@ -189,7 +188,7 @@ const SdocEditor = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
189
188
|
slateValue: slateValue,
|
|
190
189
|
updateSlateValue: onValueChange,
|
|
191
190
|
showComment: isShowComment
|
|
192
|
-
}))))
|
|
191
|
+
})))), /*#__PURE__*/_react.default.createElement(_insertElementDialog.default, {
|
|
193
192
|
editor: validEditor
|
|
194
193
|
}));
|
|
195
194
|
});
|
|
@@ -18,6 +18,7 @@ const TEXT_STYLE = exports.TEXT_STYLE = 'text_style';
|
|
|
18
18
|
const ITALIC = exports.ITALIC = 'italic';
|
|
19
19
|
const BOLD = exports.BOLD = 'bold';
|
|
20
20
|
const UNDERLINE = 'underline';
|
|
21
|
+
const INLINE_CODE = 'inline_code';
|
|
21
22
|
const HIGHLIGHT_COLOR = 'highlight_color';
|
|
22
23
|
const COLOR = 'color';
|
|
23
24
|
|
|
@@ -110,6 +111,12 @@ const MENUS_CONFIG_MAP = exports.MENUS_CONFIG_MAP = {
|
|
|
110
111
|
text: 'Underline',
|
|
111
112
|
ariaLabel: 'underline',
|
|
112
113
|
type: TEXT_STYLE_MAP.UNDERLINE
|
|
114
|
+
}, {
|
|
115
|
+
id: INLINE_CODE,
|
|
116
|
+
iconClass: 'sdocfont sdoc-inline-code',
|
|
117
|
+
text: 'Inline_code',
|
|
118
|
+
ariaLabel: 'code',
|
|
119
|
+
type: TEXT_STYLE_MAP.CODE
|
|
113
120
|
}, {
|
|
114
121
|
id: `sdoc-${HIGHLIGHT_COLOR}`,
|
|
115
122
|
iconClass: 'sdocfont sdoc-highlight-color',
|
|
@@ -7,12 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
9
9
|
var _slate = require("@seafile/slate");
|
|
10
|
+
var _core = require("../../../core");
|
|
10
11
|
var _constants = require("../../../constants");
|
|
11
12
|
const withParagraph = editor => {
|
|
12
13
|
const {
|
|
13
14
|
handleTab,
|
|
14
15
|
insertText,
|
|
15
|
-
deleteBackward
|
|
16
|
+
deleteBackward,
|
|
17
|
+
onHotKeyDown
|
|
16
18
|
} = editor;
|
|
17
19
|
const newEditor = editor;
|
|
18
20
|
newEditor.handleTab = event => {
|
|
@@ -77,6 +79,53 @@ const withParagraph = editor => {
|
|
|
77
79
|
}
|
|
78
80
|
return deleteBackward(unit);
|
|
79
81
|
};
|
|
82
|
+
newEditor.onHotKeyDown = event => {
|
|
83
|
+
const selectedParagraph = (0, _core.getSelectedNodeByType)(editor, _constants.PARAGRAPH);
|
|
84
|
+
if (selectedParagraph) {
|
|
85
|
+
const {
|
|
86
|
+
selection
|
|
87
|
+
} = newEditor;
|
|
88
|
+
if (_slate.Range.isCollapsed(selection)) {
|
|
89
|
+
if ((0, _isHotkey.default)('ArrowRight', event)) {
|
|
90
|
+
const lastLeaf = selectedParagraph.children.slice(-1)[0];
|
|
91
|
+
// When the last character of a paragraph is code text, right-click to move the cursor and insert a new text node
|
|
92
|
+
// Avoid being unable to enter new text when the code text is at the end of the paragraph
|
|
93
|
+
if (lastLeaf !== null && lastLeaf !== void 0 && lastLeaf.code) {
|
|
94
|
+
const {
|
|
95
|
+
focus
|
|
96
|
+
} = selection;
|
|
97
|
+
const [, lastPoint] = _slate.Editor.edges(newEditor, [focus.path[0]]);
|
|
98
|
+
if (_slate.Point.equals(focus, lastPoint)) {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
_slate.Editor.insertFragment(newEditor, [(0, _core.generateDefaultText)(' ')]);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if ((0, _isHotkey.default)('Enter', event)) {
|
|
106
|
+
const lastLeaf = selectedParagraph.children.slice(-1)[0];
|
|
107
|
+
// The last text node style in a paragraph is code. When pressing Enter, insert an empty node first and then split the node.
|
|
108
|
+
// Avoid empty inline nodes at the beginning of new lines
|
|
109
|
+
if (lastLeaf !== null && lastLeaf !== void 0 && lastLeaf.code) {
|
|
110
|
+
const {
|
|
111
|
+
focus
|
|
112
|
+
} = selection;
|
|
113
|
+
const [, leafPath] = _slate.Editor.leaf(newEditor, selection);
|
|
114
|
+
const [, lastPoint] = _slate.Editor.edges(newEditor, leafPath);
|
|
115
|
+
if (_slate.Point.equals(focus, lastPoint)) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
_slate.Editor.insertFragment(newEditor, [(0, _core.generateDefaultText)(' ')]);
|
|
118
|
+
_slate.Transforms.splitNodes(newEditor, {
|
|
119
|
+
always: true
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return onHotKeyDown && onHotKeyDown(event);
|
|
128
|
+
};
|
|
80
129
|
return newEditor;
|
|
81
130
|
};
|
|
82
131
|
var _default = exports.default = withParagraph;
|
|
@@ -99,14 +99,16 @@ const withSdocLink = editor => {
|
|
|
99
99
|
}
|
|
100
100
|
if (e.key === 'ArrowRight') {
|
|
101
101
|
const nextPoint = _slate.Editor.after(newEditor, selection);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
if (nextPoint) {
|
|
103
|
+
const [nextNode, nextPath] = _slate.Editor.node(newEditor, nextPoint.path, {
|
|
104
|
+
depth: 2
|
|
105
|
+
});
|
|
106
|
+
if ((nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === _constants.SDOC_LINK) {
|
|
107
|
+
const afterPointSdocLink = _slate.Editor.after(newEditor, nextPath);
|
|
108
|
+
_slate.Transforms.select(newEditor, afterPointSdocLink);
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
}
|
|
@@ -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,82 @@
|
|
|
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
|
+
require("./index.css");
|
|
13
|
+
const MIN_PANEL_WIDTH = 360;
|
|
14
|
+
const MAX_PANEL_WIDTH = 620;
|
|
15
|
+
const RightPanel = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
editor
|
|
18
|
+
} = _ref;
|
|
19
|
+
const {
|
|
20
|
+
plugins,
|
|
21
|
+
displayPluginName,
|
|
22
|
+
closePlugin
|
|
23
|
+
} = (0, _hooks.usePlugins)();
|
|
24
|
+
const panelWrapperRef = (0, _react.useRef)(null);
|
|
25
|
+
const {
|
|
26
|
+
collaborators
|
|
27
|
+
} = (0, _hooks.useCollaborators)();
|
|
28
|
+
const [width, setWidth] = (0, _react.useState)(MIN_PANEL_WIDTH);
|
|
29
|
+
const panelWrapperStyle = (0, _react.useMemo)(() => {
|
|
30
|
+
if (!displayPluginName) return null;
|
|
31
|
+
let style = {
|
|
32
|
+
width,
|
|
33
|
+
zIndex: 101
|
|
34
|
+
};
|
|
35
|
+
if (!style.width || style.width < MIN_PANEL_WIDTH) {
|
|
36
|
+
style.width = MIN_PANEL_WIDTH;
|
|
37
|
+
} else if (style.width > MAX_PANEL_WIDTH) {
|
|
38
|
+
style.width = MAX_PANEL_WIDTH;
|
|
39
|
+
}
|
|
40
|
+
return style;
|
|
41
|
+
}, [width, displayPluginName]);
|
|
42
|
+
const resizeWidth = (0, _react.useCallback)(width => {
|
|
43
|
+
setWidth(width);
|
|
44
|
+
}, [panelWrapperRef]);
|
|
45
|
+
const resizeWidthEnd = (0, _react.useCallback)(width => {
|
|
46
|
+
const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}'));
|
|
47
|
+
window.localStorage.setItem('sdoc-panel-width', JSON.stringify({
|
|
48
|
+
...panelWidth,
|
|
49
|
+
[displayPluginName]: width
|
|
50
|
+
}));
|
|
51
|
+
}, [displayPluginName]);
|
|
52
|
+
(0, _react.useEffect)(() => {
|
|
53
|
+
const panelWidth = JSON.parse(window.localStorage.getItem('sdoc-panel-width', '{}')) || {};
|
|
54
|
+
const width = Math.max(parseInt(panelWidth[displayPluginName] || MIN_PANEL_WIDTH), MAX_PANEL_WIDTH);
|
|
55
|
+
setWidth(width);
|
|
56
|
+
}, [displayPluginName]);
|
|
57
|
+
if (!displayPluginName) return null;
|
|
58
|
+
const plugin = plugins.find(p => p.name === displayPluginName);
|
|
59
|
+
if (!plugin) return null;
|
|
60
|
+
const Component = plugin.Component;
|
|
61
|
+
if (!Component) return null;
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
63
|
+
className: "sdoc-content-right-panel-wrapper",
|
|
64
|
+
ref: panelWrapperRef,
|
|
65
|
+
style: panelWrapperStyle
|
|
66
|
+
}, plugin.resizable_width && /*#__PURE__*/_react.default.createElement(_resizeWidth.default, {
|
|
67
|
+
minWidth: MIN_PANEL_WIDTH,
|
|
68
|
+
maxWidth: MAX_PANEL_WIDTH,
|
|
69
|
+
resizeWidth: resizeWidth,
|
|
70
|
+
resizeWidthEnd: resizeWidthEnd
|
|
71
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
+
className: "sdoc-content-right-panel",
|
|
73
|
+
id: "sdoc-content-right-panel"
|
|
74
|
+
}, /*#__PURE__*/_react.default.createElement(Component, {
|
|
75
|
+
editor: editor,
|
|
76
|
+
type: "global",
|
|
77
|
+
collaborators: collaborators,
|
|
78
|
+
onClose: closePlugin,
|
|
79
|
+
width: width
|
|
80
|
+
})));
|
|
81
|
+
};
|
|
82
|
+
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,8 +11,8 @@ 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"));
|
|
15
|
+
var _pluginsOperations = _interopRequireDefault(require("./plugins-operations"));
|
|
16
16
|
var _utils = require("../../utils");
|
|
17
17
|
require("./style.css");
|
|
18
18
|
const DocOperations = _ref => {
|
|
@@ -39,6 +39,6 @@ const DocOperations = _ref => {
|
|
|
39
39
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
40
40
|
handleRevisionMerged: handleRevisionMerged,
|
|
41
41
|
handleRevisionPublished: handleRevisionPublished
|
|
42
|
-
}), !
|
|
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));
|
|
43
43
|
};
|
|
44
44
|
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(DocOperations);
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
var _hooks = require("../../hooks");
|
|
12
|
+
var _mouseEvent = require("../../basic-sdk/utils/mouse-event");
|
|
13
|
+
const PluginsOperations = () => {
|
|
14
|
+
const {
|
|
15
|
+
plugins,
|
|
16
|
+
updateDisplayPlugin
|
|
17
|
+
} = (0, _hooks.usePlugins)();
|
|
18
|
+
const onClick = (0, _react.useCallback)((event, pluginName) => {
|
|
19
|
+
(0, _mouseEvent.eventStopPropagation)(event);
|
|
20
|
+
updateDisplayPlugin(pluginName);
|
|
21
|
+
}, [updateDisplayPlugin]);
|
|
22
|
+
return plugins.map(plugin => {
|
|
23
|
+
const {
|
|
24
|
+
name,
|
|
25
|
+
icon
|
|
26
|
+
} = plugin;
|
|
27
|
+
let iconDom = '';
|
|
28
|
+
if (typeof icon !== 'string') {
|
|
29
|
+
iconDom = icon;
|
|
30
|
+
} else {
|
|
31
|
+
iconDom = /*#__PURE__*/_react.default.createElement("i", {
|
|
32
|
+
className: (0, _classnames.default)('sdocfont', icon)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
36
|
+
className: "op-item sdoc-plugin-operation-btn-container",
|
|
37
|
+
onClick: e => onClick(e, name),
|
|
38
|
+
key: name
|
|
39
|
+
}, iconDom);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var _default = exports.default = PluginsOperations;
|
package/dist/hooks/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "CollaboratorsProvider", {
|
|
|
9
9
|
return _useCollaborators.CollaboratorsProvider;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "PluginsProvider", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _usePlugins.PluginsProvider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "useCollaborators", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function () {
|
|
@@ -21,5 +27,12 @@ Object.defineProperty(exports, "useDocument", {
|
|
|
21
27
|
return _useDocument.useDocument;
|
|
22
28
|
}
|
|
23
29
|
});
|
|
30
|
+
Object.defineProperty(exports, "usePlugins", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _usePlugins.usePlugins;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
24
36
|
var _useCollaborators = require("./use-collaborators");
|
|
25
|
-
var _useDocument = require("./use-document");
|
|
37
|
+
var _useDocument = require("./use-document");
|
|
38
|
+
var _usePlugins = require("./use-plugins");
|
|
@@ -10,12 +10,17 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _context = _interopRequireDefault(require("../context"));
|
|
11
11
|
var _model = require("../model");
|
|
12
12
|
const CollaboratorsContext = /*#__PURE__*/_react.default.createContext(null);
|
|
13
|
-
const CollaboratorsProvider =
|
|
13
|
+
const CollaboratorsProvider = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
collaborators: propsCollaborators,
|
|
16
|
+
children
|
|
17
|
+
} = _ref;
|
|
14
18
|
const isSdocRevision = _context.default.getSetting('isSdocRevision');
|
|
15
19
|
const isPublished = _context.default.getSetting('isPublished');
|
|
16
|
-
const [collaborators, setCollaborators] = (0, _react.useState)([]);
|
|
20
|
+
const [collaborators, setCollaborators] = (0, _react.useState)(propsCollaborators || []);
|
|
17
21
|
(0, _react.useEffect)(() => {
|
|
18
22
|
if (isSdocRevision && isPublished) return;
|
|
23
|
+
if (propsCollaborators) return;
|
|
19
24
|
_context.default.listRelatedUsers().then(res => {
|
|
20
25
|
const collaborators = [];
|
|
21
26
|
res.data.related_users.forEach(user => {
|
|
@@ -34,7 +39,7 @@ const CollaboratorsProvider = props => {
|
|
|
34
39
|
value: {
|
|
35
40
|
collaborators
|
|
36
41
|
}
|
|
37
|
-
},
|
|
42
|
+
}, children);
|
|
38
43
|
};
|
|
39
44
|
exports.CollaboratorsProvider = CollaboratorsProvider;
|
|
40
45
|
const useCollaborators = () => {
|
|
@@ -0,0 +1,64 @@
|
|
|
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.usePlugins = exports.PluginsProvider = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _constants = require("../basic-sdk/constants");
|
|
11
|
+
var _comment = _interopRequireDefault(require("../basic-sdk/comment"));
|
|
12
|
+
const PluginsContext = /*#__PURE__*/_react.default.createContext(null);
|
|
13
|
+
const PluginsProvider = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
showComment,
|
|
16
|
+
plugins: propsPlugins,
|
|
17
|
+
children
|
|
18
|
+
} = _ref;
|
|
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('');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
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);
|
|
45
|
+
}
|
|
46
|
+
}, [displayName, plugins]);
|
|
47
|
+
return /*#__PURE__*/_react.default.createElement(PluginsContext.Provider, {
|
|
48
|
+
value: {
|
|
49
|
+
plugins,
|
|
50
|
+
displayPluginName: displayName,
|
|
51
|
+
updateDisplayPlugin,
|
|
52
|
+
closePlugin
|
|
53
|
+
}
|
|
54
|
+
}, children);
|
|
55
|
+
};
|
|
56
|
+
exports.PluginsProvider = PluginsProvider;
|
|
57
|
+
const usePlugins = () => {
|
|
58
|
+
const context = (0, _react.useContext)(PluginsContext);
|
|
59
|
+
if (!context) {
|
|
60
|
+
throw new Error('\'PluginsContext\' is null');
|
|
61
|
+
}
|
|
62
|
+
return context;
|
|
63
|
+
};
|
|
64
|
+
exports.usePlugins = usePlugins;
|
|
@@ -26,7 +26,9 @@ const SimpleEditor = _ref => {
|
|
|
26
26
|
showComment,
|
|
27
27
|
showDocOperations = true,
|
|
28
28
|
showFileTags = true,
|
|
29
|
-
t
|
|
29
|
+
t,
|
|
30
|
+
plugins = [],
|
|
31
|
+
collaborators
|
|
30
32
|
} = _ref;
|
|
31
33
|
_context.default.initApi();
|
|
32
34
|
const editorRef = (0, _react.useRef)(null);
|
|
@@ -140,7 +142,12 @@ const SimpleEditor = _ref => {
|
|
|
140
142
|
className: "error-tip"
|
|
141
143
|
}, t(errorMessage)));
|
|
142
144
|
}
|
|
143
|
-
return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(
|
|
145
|
+
return /*#__PURE__*/_react.default.createElement(_errorBoundary.default, null, /*#__PURE__*/_react.default.createElement(_hooks.CollaboratorsProvider, {
|
|
146
|
+
collaborators: collaborators
|
|
147
|
+
}, /*#__PURE__*/_react.default.createElement(_hooks.PluginsProvider, {
|
|
148
|
+
plugins: plugins,
|
|
149
|
+
showComment: showComment
|
|
150
|
+
}, /*#__PURE__*/_react.default.createElement(_layout.default, null, /*#__PURE__*/_react.default.createElement(_layout.Header, null, /*#__PURE__*/_react.default.createElement(_docInfo.default, {
|
|
144
151
|
isStarred: isStarred,
|
|
145
152
|
isDraft: isDraft,
|
|
146
153
|
showFileTags: showFileTags,
|
|
@@ -153,6 +160,6 @@ const SimpleEditor = _ref => {
|
|
|
153
160
|
handleViewChangesToggle: handleViewChangesToggle,
|
|
154
161
|
handleRevisionMerged: handleRevisionMerged,
|
|
155
162
|
handleRevisionPublished: handleRevisionPublished
|
|
156
|
-
})), /*#__PURE__*/_react.default.createElement(_layout.Content, null, renderEditor())));
|
|
163
|
+
})), /*#__PURE__*/_react.default.createElement(_layout.Content, null, renderEditor())))));
|
|
157
164
|
};
|
|
158
165
|
var _default = exports.default = (0, _reactI18next.withTranslation)('sdoc-editor')(SimpleEditor);
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="sdoc-info" unicode="" d="M512 896c281.6 0 512-230.4 512-512s-230.4-512-512-512S0 102.4 0 384 230.4 896 512 896z m0-96C281.6 800 96 614.4 96 384s185.6-416 416-416 416 185.6 416 416c0 108.8-44.8 217.6-121.6 294.4S620.8 800 512 800z m32-352c19.2 0 32-12.8 32-32v-256c0-19.2-12.8-32-32-32h-64c-19.2 0-32 12.8-32 32V416c0 19.2 12.8 32 32 32h64z m-19.2 192c9.6 0 16-3.2 22.4-9.6 3.2-3.2 6.4-6.4 9.6-6.4 25.6-25.6 25.6-64 0-89.6-3.2-3.2-6.4-6.4-9.6-6.4-6.4-3.2-16-6.4-22.4-9.6h-25.6c-9.6 0-16 3.2-22.4 9.6-3.2 3.2-6.4 6.4-9.6 6.4-25.6 25.6-25.6 64 0 89.6 3.2 3.2 6.4 6.4 9.6 6.4 6.4 3.2 16 6.4 22.4 9.6h25.6z" horiz-adv-x="1024" />
|
|
18
|
+
|
|
19
|
+
<glyph glyph-name="sdoc-inline-code" unicode="" d="M1024 384l-272-288-67.2 70.4 204.8 217.6-204.8 217.6L752 672l272-288zM0 384l272-288 67.2 70.4L134.4 384l204.8 217.6L272 672 0 384z m451.2-512l-99.2 3.2L579.2 896h99.2l-227.2-1024z" horiz-adv-x="1024" />
|
|
20
|
+
|
|
17
21
|
<glyph glyph-name="sdoc-sort" unicode="" d="M294.4 790.4l201.6-204.8c19.2-19.2 19.2-51.2 0-73.6-19.2-19.2-51.2-19.2-70.4 0L320 620.8v-604.8c0-25.6-22.4-48-48-48S224-9.6 224 16V620.8L118.4 512c-19.2-19.2-48-19.2-67.2-3.2l-3.2 3.2c-19.2 19.2-19.2 51.2 0 73.6l201.6 204.8c12.8 12.8 32 12.8 44.8 0zM752 800c25.6 0 48-22.4 48-48v-604.8l105.6 108.8c19.2 19.2 51.2 19.2 70.4 0 19.2-19.2 19.2-51.2 0-73.6l-201.6-204.8c-12.8-12.8-32-12.8-44.8 0l-201.6 204.8c-19.2 19.2-19.2 51.2 0 73.6l3.2 3.2c19.2 16 48 16 67.2-3.2l105.6-108.8V752c0 25.6 22.4 48 48 48z" horiz-adv-x="1024" />
|
|
18
22
|
|
|
19
23
|
<glyph glyph-name="sdoc-set-up" unicode="" d="M598.52384 809.6l12.8-92.8 6.4-38.4 35.2-16c12.8-6.4 28.8-16 41.6-25.6l32-19.2 35.2 12.8 92.8 35.2 86.4-140.8-76.8-54.4-32-25.6 3.2-38.4v-44.8l-3.2-38.4 32-25.6 76.8-57.6-83.2-140.8-92.8 35.2-35.2 12.8-32-19.2c-12.8-9.6-28.8-19.2-41.6-25.6l-35.2-16-6.4-38.4-12.8-92.8h-172.8l-12.8 92.8-6.4 38.4-35.2 16c-12.8 6.4-28.8 16-41.6 25.6l-32 19.2-35.2-12.8-92.8-35.2-86.4 140.8L160.12384 297.6l32 25.6-3.2 38.4V384v22.4l3.2 38.4-32 25.6-76.8 57.6 83.2 140.8 92.8-35.2 35.2-12.8 32 19.2c12.8 9.6 28.8 19.2 41.6 25.6l35.2 16 6.4 38.4 12.8 92.8h176m12.8 83.2H416.12384c-32 0-57.6-22.4-60.8-51.2l-16-105.6c-19.2-9.6-35.2-19.2-54.4-32L182.52384 748.8c-9.6 3.2-16 3.2-22.4 3.2-22.4 0-41.6-9.6-54.4-28.8L6.52384 560c-12.8-28.8-6.4-60.8 16-80l86.4-67.2c0-9.6-3.2-22.4-3.2-28.8 0-9.6 0-19.2 3.2-28.8L22.52384 288c-22.4-19.2-28.8-51.2-16-76.8l96-163.2c9.6-19.2 32-32 54.4-32 6.4 0 12.8 0 22.4 3.2l102.4 41.6c16-12.8 35.2-22.4 54.4-28.8l16-105.6c3.2-28.8 28.8-51.2 60.8-51.2H608.12384c32 0 57.6 22.4 60.8 51.2l16 105.6c19.2 9.6 35.2 19.2 54.4 28.8l102.4-41.6c6.4-3.2 16-3.2 22.4-3.2 22.4 0 41.6 9.6 54.4 28.8l99.2 166.4c16 25.6 9.6 57.6-16 76.8l-86.4 67.2c0 9.6 3.2 19.2 3.2 28.8s0 22.4-3.2 28.8l86.4 67.2c22.4 19.2 28.8 51.2 16 76.8l-96 163.2c-9.6 19.2-32 32-54.4 32-6.4 0-12.8 0-22.4-3.2l-102.4-41.6c-16 12.8-35.2 22.4-54.4 28.8L672.12384 844.8C665.72384 873.6 640.12384 896 611.32384 896zM512.12384 512c70.4 0 128-57.6 128-128s-57.6-128-128-128-128 57.6-128 128 57.6 128 128 128m0 86.4a214.4 214.4 0 1 1 0-428.8 214.4 214.4 0 0 1 0 428.8z" horiz-adv-x="1026" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "sdocfont"; /* Project id 4097705 */
|
|
3
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
4
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./sdoc-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./sdoc-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./sdoc-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./sdoc-editor-font/iconfont.svg?t=
|
|
3
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1725002301707'); /* IE9 */
|
|
4
|
+
src: url('./sdoc-editor-font/iconfont.eot?t=1725002301707#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
|
5
|
+
url('./sdoc-editor-font/iconfont.woff2?t=1725002301707') format('woff2'),
|
|
6
|
+
url('./sdoc-editor-font/iconfont.woff?t=1725002301707') format('woff'),
|
|
7
|
+
url('./sdoc-editor-font/iconfont.ttf?t=1725002301707') format('truetype'),
|
|
8
|
+
url('./sdoc-editor-font/iconfont.svg?t=1725002301707#sdocfont') format('svg');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.sdoc-info:before {
|
|
20
|
+
content: "\e677";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sdoc-inline-code:before {
|
|
24
|
+
content: "\e676";
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
.sdoc-sort:before {
|
|
20
28
|
content: "\e674";
|
|
21
29
|
}
|