@seafile/sdoc-editor 2.0.175 → 2.0.177
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.
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
|
+
var _regeneratorValues2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorValues"));
|
|
9
10
|
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regenerator"));
|
|
10
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
11
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
@@ -13,9 +14,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm
|
|
|
13
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
15
|
var _reactI18next = require("react-i18next");
|
|
15
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
|
-
var _slugid = _interopRequireDefault(require("slugid"));
|
|
17
17
|
var _toast = _interopRequireDefault(require("../../../../components/toast"));
|
|
18
|
-
var
|
|
18
|
+
var _context4 = _interopRequireDefault(require("../../../../context"));
|
|
19
19
|
var _commonUtils = require("../../../../utils/common-utils");
|
|
20
20
|
var _helpers = require("../helpers");
|
|
21
21
|
require("./index.css");
|
|
@@ -61,13 +61,89 @@ var LocalFiles = function LocalFiles(_ref) {
|
|
|
61
61
|
setTreeData((0, _toConsumableArray2["default"])(data));
|
|
62
62
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
63
|
}, []);
|
|
64
|
+
var expandPath = /*#__PURE__*/function () {
|
|
65
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee(currentDirPath, currentDirId, treeData) {
|
|
66
|
+
var pathParts, currentLevel, _loop, _ret, i;
|
|
67
|
+
return (0, _regenerator2["default"])().w(function (_context2) {
|
|
68
|
+
while (1) switch (_context2.n) {
|
|
69
|
+
case 0:
|
|
70
|
+
pathParts = currentDirPath.split('/').filter(Boolean);
|
|
71
|
+
currentLevel = treeData;
|
|
72
|
+
_loop = /*#__PURE__*/(0, _regenerator2["default"])().m(function _loop() {
|
|
73
|
+
var dirName, currentItem;
|
|
74
|
+
return (0, _regenerator2["default"])().w(function (_context) {
|
|
75
|
+
while (1) switch (_context.n) {
|
|
76
|
+
case 0:
|
|
77
|
+
dirName = pathParts[i];
|
|
78
|
+
currentItem = currentLevel.find(function (item) {
|
|
79
|
+
return item.name === dirName && item.type === 'dir';
|
|
80
|
+
});
|
|
81
|
+
if (currentItem) {
|
|
82
|
+
_context.n = 1;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
return _context.a(2, 0);
|
|
86
|
+
case 1:
|
|
87
|
+
_context.n = 2;
|
|
88
|
+
return onToggle(null, currentItem, treeData);
|
|
89
|
+
case 2:
|
|
90
|
+
if (!(currentDirId === currentItem.indexId)) {
|
|
91
|
+
_context.n = 3;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
return _context.a(2, 0);
|
|
95
|
+
case 3:
|
|
96
|
+
currentLevel = currentItem.children || [];
|
|
97
|
+
case 4:
|
|
98
|
+
return _context.a(2);
|
|
99
|
+
}
|
|
100
|
+
}, _loop);
|
|
101
|
+
});
|
|
102
|
+
i = 0;
|
|
103
|
+
case 1:
|
|
104
|
+
if (!(i < pathParts.length)) {
|
|
105
|
+
_context2.n = 4;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return _context2.d((0, _regeneratorValues2["default"])(_loop()), 2);
|
|
109
|
+
case 2:
|
|
110
|
+
_ret = _context2.v;
|
|
111
|
+
if (!(_ret === 0)) {
|
|
112
|
+
_context2.n = 3;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context2.a(3, 4);
|
|
116
|
+
case 3:
|
|
117
|
+
i++;
|
|
118
|
+
_context2.n = 1;
|
|
119
|
+
break;
|
|
120
|
+
case 4:
|
|
121
|
+
return _context2.a(2);
|
|
122
|
+
}
|
|
123
|
+
}, _callee);
|
|
124
|
+
}));
|
|
125
|
+
return function expandPath(_x, _x2, _x3) {
|
|
126
|
+
return _ref2.apply(this, arguments);
|
|
127
|
+
};
|
|
128
|
+
}();
|
|
64
129
|
var getTreeData = (0, _react.useCallback)(function (p, indexId, treeData) {
|
|
65
|
-
return
|
|
130
|
+
return _context4["default"].getSdocLocalFiles(p, fileType).then(function (res) {
|
|
66
131
|
res.data.forEach(function (item) {
|
|
67
|
-
item.
|
|
132
|
+
item.path = "/".concat(item.name);
|
|
133
|
+
item.indexId = item.id;
|
|
68
134
|
});
|
|
69
135
|
setHasSearchResult(false);
|
|
70
136
|
setIsCurrentLibrary(true);
|
|
137
|
+
|
|
138
|
+
// Open current directory by default
|
|
139
|
+
if (!indexId && !treeData) {
|
|
140
|
+
var currentDirPath = _context4["default"].getSetting('docPath').split('/').slice(0, -1).join('/');
|
|
141
|
+
if (currentDirPath) {
|
|
142
|
+
var currentDirId = _context4["default"].getSetting('currentDirId');
|
|
143
|
+
expandPath(currentDirPath, currentDirId, res.data);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
71
147
|
// Open folder
|
|
72
148
|
if (indexId && treeData.length > 0) {
|
|
73
149
|
var newFileListData = (0, _helpers.addDataToTree)(treeData, indexId, res.data, p);
|
|
@@ -97,21 +173,21 @@ var LocalFiles = function LocalFiles(_ref) {
|
|
|
97
173
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
174
|
}, [isOpenSearch, searchContent, isOpenSearch]);
|
|
99
175
|
var onToggle = (0, _react.useCallback)(/*#__PURE__*/function () {
|
|
100
|
-
var
|
|
101
|
-
return (0, _regenerator2["default"])().w(function (
|
|
102
|
-
while (1) switch (
|
|
176
|
+
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/(0, _regenerator2["default"])().m(function _callee2(e, item, treeData) {
|
|
177
|
+
return (0, _regenerator2["default"])().w(function (_context3) {
|
|
178
|
+
while (1) switch (_context3.n) {
|
|
103
179
|
case 0:
|
|
104
|
-
e.stopPropagation();
|
|
180
|
+
e && e.stopPropagation();
|
|
105
181
|
if (!expandedFolder.has(item.indexId)) {
|
|
106
|
-
|
|
182
|
+
_context3.n = 1;
|
|
107
183
|
break;
|
|
108
184
|
}
|
|
109
185
|
collapsedFolder(treeData, item.indexId);
|
|
110
186
|
expandedFolder["delete"](item.indexId);
|
|
111
|
-
|
|
187
|
+
_context3.n = 3;
|
|
112
188
|
break;
|
|
113
189
|
case 1:
|
|
114
|
-
|
|
190
|
+
_context3.n = 2;
|
|
115
191
|
return getTreeData(item.path, item.indexId, treeData);
|
|
116
192
|
case 2:
|
|
117
193
|
expandedFolder.add(item.indexId);
|
|
@@ -121,12 +197,12 @@ var LocalFiles = function LocalFiles(_ref) {
|
|
|
121
197
|
setExpandedFolder(new Set(Array.from(expandedFolder)));
|
|
122
198
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
199
|
case 4:
|
|
124
|
-
return
|
|
200
|
+
return _context3.a(2);
|
|
125
201
|
}
|
|
126
|
-
},
|
|
202
|
+
}, _callee2);
|
|
127
203
|
}));
|
|
128
|
-
return function (
|
|
129
|
-
return
|
|
204
|
+
return function (_x4, _x5, _x6) {
|
|
205
|
+
return _ref3.apply(this, arguments);
|
|
130
206
|
};
|
|
131
207
|
}(), [expandedFolder]);
|
|
132
208
|
var onSelectFile = (0, _react.useCallback)(function (e, file) {
|
|
@@ -136,9 +212,9 @@ var LocalFiles = function LocalFiles(_ref) {
|
|
|
136
212
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
137
213
|
}, []);
|
|
138
214
|
var getSearchFiles = (0, _react.useCallback)(function (searchContent, fileType) {
|
|
139
|
-
return
|
|
215
|
+
return _context4["default"].getSearchFilesByFilename(searchContent, 1, 100, fileType).then(function (res) {
|
|
140
216
|
res.data.results.forEach(function (item) {
|
|
141
|
-
item.indexId =
|
|
217
|
+
item.indexId = item.id;
|
|
142
218
|
item.type = 'file';
|
|
143
219
|
item.file_uuid = item.doc_uuid;
|
|
144
220
|
});
|
|
@@ -39,3 +39,22 @@
|
|
|
39
39
|
position: relative;
|
|
40
40
|
z-index: 1;
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
.whiteboard-zoom-out-container {
|
|
44
|
+
position: fixed;
|
|
45
|
+
inset: 0;
|
|
46
|
+
background: rgba(0, 0, 0, 0.7);
|
|
47
|
+
display: flex;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
align-items: center;
|
|
50
|
+
z-index: 9999;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.whiteboard-zoom-out-container .sdoc-whiteboard-element-full-screen {
|
|
54
|
+
pointer-events: auto;
|
|
55
|
+
background: #fff;
|
|
56
|
+
border-radius: 12px;
|
|
57
|
+
width: 80%;
|
|
58
|
+
height: 80%;
|
|
59
|
+
overflow: auto;
|
|
60
|
+
}
|
|
@@ -9,6 +9,7 @@ exports.renderWhiteboard = renderWhiteboard;
|
|
|
9
9
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
12
13
|
var _slate = require("@seafile/slate");
|
|
13
14
|
var _slateReact = require("@seafile/slate-react");
|
|
14
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -38,14 +39,20 @@ var Whiteboard = function Whiteboard(_ref) {
|
|
|
38
39
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
39
40
|
menuPosition = _useState2[0],
|
|
40
41
|
setMenuPosition = _useState2[1];
|
|
42
|
+
var _useState3 = (0, _react.useState)(false),
|
|
43
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
44
|
+
isShowZoomOut = _useState4[0],
|
|
45
|
+
setIsShowZoomOut = _useState4[1];
|
|
41
46
|
(0, _react.useEffect)(function () {
|
|
42
47
|
var handleMessage = function handleMessage(event) {
|
|
43
48
|
var _event$data;
|
|
44
49
|
if (((_event$data = event.data) === null || _event$data === void 0 ? void 0 : _event$data.type) === 'checkSdocParent') {
|
|
45
50
|
var isSdocClass = whiteboardRef === null || whiteboardRef === void 0 ? void 0 : whiteboardRef.current.classList.contains('sdoc-whiteboard-element');
|
|
51
|
+
var isWhiteboardFullScreen = whiteboardRef === null || whiteboardRef === void 0 ? void 0 : whiteboardRef.current.classList.contains('sdoc-whiteboard-element-full-screen');
|
|
46
52
|
whiteboardRef === null || whiteboardRef === void 0 ? void 0 : whiteboardRef.current.contentWindow.postMessage({
|
|
47
53
|
type: 'checkSdocParentResult',
|
|
48
|
-
isInSdoc: isSdocClass
|
|
54
|
+
isInSdoc: isSdocClass,
|
|
55
|
+
isFullScreen: isWhiteboardFullScreen
|
|
49
56
|
}, '*');
|
|
50
57
|
}
|
|
51
58
|
};
|
|
@@ -123,18 +130,23 @@ var Whiteboard = function Whiteboard(_ref) {
|
|
|
123
130
|
setMenuPosition(_menuPosition);
|
|
124
131
|
}
|
|
125
132
|
}, [editor, isSelected, readOnly]);
|
|
126
|
-
var openFullscreen = function openFullscreen() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
whiteboardRef.current.requestFullscreen();
|
|
130
|
-
} else if (whiteboardRef.current.webkitRequestFullscreen) {
|
|
131
|
-
// Safari
|
|
132
|
-
whiteboardRef.current.webkitRequestFullscreen();
|
|
133
|
-
} else if (whiteboardRef.current.msRequestFullscreen) {
|
|
134
|
-
// IE11
|
|
135
|
-
whiteboardRef.current.msRequestFullscreen();
|
|
136
|
-
}
|
|
133
|
+
var openFullscreen = function openFullscreen(e) {
|
|
134
|
+
e.stopPropagation();
|
|
135
|
+
setIsShowZoomOut(true);
|
|
137
136
|
};
|
|
137
|
+
(0, _react.useEffect)(function () {
|
|
138
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
139
|
+
if (e.key === 'Escape') {
|
|
140
|
+
setIsShowZoomOut(false);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
if (isShowZoomOut) {
|
|
144
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
145
|
+
}
|
|
146
|
+
return function () {
|
|
147
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
148
|
+
};
|
|
149
|
+
}, [isShowZoomOut, setIsShowZoomOut]);
|
|
138
150
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
139
151
|
className: (0, _classnames["default"])('sdoc-whiteboard-container', {
|
|
140
152
|
'isSelected': isSelected
|
|
@@ -152,12 +164,21 @@ var Whiteboard = function Whiteboard(_ref) {
|
|
|
152
164
|
className: "iframe-overlay",
|
|
153
165
|
onDoubleClick: handleDoubleClick,
|
|
154
166
|
onClick: handleOnClick
|
|
155
|
-
})), isSelected && !readOnly && /*#__PURE__*/_react["default"].createElement(_hoverMenu["default"], {
|
|
167
|
+
})), isSelected && !readOnly && !isShowZoomOut && /*#__PURE__*/_react["default"].createElement(_hoverMenu["default"], {
|
|
156
168
|
menuPosition: menuPosition,
|
|
157
169
|
onOpen: handleDoubleClick,
|
|
158
170
|
openFullscreen: openFullscreen,
|
|
159
171
|
onDeleteWhiteboard: onDeleteWhiteboard
|
|
160
|
-
})
|
|
172
|
+
}), isShowZoomOut && (/*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement("div", {
|
|
173
|
+
className: "whiteboard-zoom-out-container",
|
|
174
|
+
onClick: function onClick() {
|
|
175
|
+
return setIsShowZoomOut(false);
|
|
176
|
+
}
|
|
177
|
+
}, /*#__PURE__*/_react["default"].createElement("iframe", {
|
|
178
|
+
className: "sdoc-whiteboard-element-full-screen",
|
|
179
|
+
src: link,
|
|
180
|
+
ref: whiteboardRef
|
|
181
|
+
})), document.body)));
|
|
161
182
|
};
|
|
162
183
|
function renderWhiteboard(props, editor) {
|
|
163
184
|
var element = props.element,
|
|
@@ -8,7 +8,7 @@ var _helper = require("../comment/helper");
|
|
|
8
8
|
var _constants = require("../constants");
|
|
9
9
|
var _useScrollContext = require("./use-scroll-context");
|
|
10
10
|
var useCommentListPosition = exports.useCommentListPosition = function useCommentListPosition(selectedElementIds, isContextComment, isClickedContextComment, commentedDom, commentDetail, closeComment, editor) {
|
|
11
|
-
var _document$
|
|
11
|
+
var _document$querySelect2;
|
|
12
12
|
var headerHeight = 100;
|
|
13
13
|
var scrollRef = (0, _useScrollContext.useScrollContext)();
|
|
14
14
|
var _ref = scrollRef.current || {},
|
|
@@ -17,7 +17,9 @@ var useCommentListPosition = exports.useCommentListPosition = function useCommen
|
|
|
17
17
|
if (isContextComment || isClickedContextComment) {
|
|
18
18
|
var rect;
|
|
19
19
|
if (isContextComment) {
|
|
20
|
-
|
|
20
|
+
var _document$querySelect;
|
|
21
|
+
var commentedDomId = commentedDom.getAttribute('data-id');
|
|
22
|
+
rect = (_document$querySelect = document.querySelector("[data-id=\"".concat(commentedDomId, "\"]"))) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getBoundingClientRect();
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
// rect is the last commented context dom
|
|
@@ -65,7 +67,7 @@ var useCommentListPosition = exports.useCommentListPosition = function useCommen
|
|
|
65
67
|
y: topPara
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
|
-
var selectionPosition = (_document$
|
|
70
|
+
var selectionPosition = (_document$querySelect2 = document.querySelectorAll("[data-id=\"".concat(selectedElementIds[0], "\"]"))[0]) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.getBoundingClientRect();
|
|
69
71
|
// Boundary check
|
|
70
72
|
if (!selectionPosition) closeComment();
|
|
71
73
|
if (selectionPosition && selectionPosition.y !== 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/sdoc-editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.177",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "471a56e253db6798199eee066673bc59a9f6172b"
|
|
75
75
|
}
|