@seafile/comment-editor 0.0.9 → 0.0.11-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/basic-sdk/assets/css/layout.css +0 -111
- package/dist/basic-sdk/assets/css/sdoc-comment-editor-plugin.css +1 -6
- package/dist/basic-sdk/extension/plugins/image/helpers.js +9 -5
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +3 -2
- package/dist/basic-sdk/extension/plugins/image/use-copy-image.js +3 -2
- package/dist/basic-sdk/extension/plugins/image/use-upload-image.js +4 -5
- package/package.json +4 -4
- package/dist/basic-sdk/assets/css/sdoc-viewer.css +0 -14
|
@@ -1,116 +1,5 @@
|
|
|
1
|
-
.sdoc-editor-container.fullscreen .sdoc-content-wrapper {
|
|
2
|
-
height: 100vh !important;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.sdoc-editor-container.fullscreen .sdoc-article-container {
|
|
6
|
-
width: 100% !important;
|
|
7
|
-
padding: 0 !important;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.sdoc-editor-container.fullscreen .sdoc-editor__article {
|
|
11
|
-
padding: calc(100vw / 794 * 40) calc(100vw / 794 * 60) !important;
|
|
12
|
-
font-size: calc(100vw / 794 * 14.7) !important;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.sdoc-editor-container.fullscreen .sdoc-checkbox-input {
|
|
16
|
-
width: calc(100vw / 794 * 13) !important;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.sdoc-editor-container.fullscreen .sdoc-code-block-pre {
|
|
20
|
-
font-size: calc(100vw / 794 * 13.3) !important;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.sdoc-editor-container.fullscreen .sdoc-header-title {
|
|
24
|
-
font-size: calc(100vw / 794 * 33.7) !important;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.sdoc-editor-container.fullscreen .sdoc-header-subtitle {
|
|
28
|
-
font-size: calc(100vw / 794 * 20) !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.sdoc-editor-container.fullscreen .sdoc-header-1 {
|
|
32
|
-
font-size: calc(100vw / 794 * 26.7) !important;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.sdoc-editor-container.fullscreen .sdoc-header-2 {
|
|
36
|
-
font-size: calc(100vw / 794 * 21.3) !important;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.sdoc-editor-container.fullscreen .sdoc-header-3 {
|
|
40
|
-
font-size: calc(100vw / 794 * 18.7) !important;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.sdoc-editor-container.fullscreen .sdoc-header-4 {
|
|
44
|
-
font-size: calc(100vw / 794 * 16) !important;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.sdoc-editor-container.fullscreen .sdoc-header-5,
|
|
48
|
-
.sdoc-editor-container.fullscreen .sdoc-header-6 {
|
|
49
|
-
font-size: calc(100vw / 794 * 14.7) !important;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.sdoc-editor-container {
|
|
53
|
-
flex: 1;
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-direction: column;
|
|
56
|
-
min-height: 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.sdoc-editor-container .sdoc-editor-toolbar {
|
|
60
|
-
display: flex;
|
|
61
|
-
flex: 1;
|
|
62
|
-
justify-content: center;
|
|
63
|
-
position: relative;
|
|
64
|
-
height: 44px;
|
|
65
|
-
align-items: center;
|
|
66
|
-
padding: 0 10px;
|
|
67
|
-
background-color: #fff;
|
|
68
|
-
user-select: none;
|
|
69
|
-
border-bottom: 1px solid #e5e6e8;
|
|
70
|
-
position: relative;
|
|
71
|
-
z-index: 102;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.sdoc-editor-container .sdoc-editor-toolbar .sdoc-editor-toolbar-right-menu {
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: row-reverse;
|
|
77
|
-
position: absolute;
|
|
78
|
-
right: 8px;
|
|
79
|
-
border-right: none;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
1
|
.sdoc-content-wrapper {
|
|
83
2
|
width: 100%;
|
|
84
3
|
height: calc(100vh - 44px);
|
|
85
4
|
display: flex;
|
|
86
5
|
}
|
|
87
|
-
|
|
88
|
-
.sdoc-editor-container .sdoc-editor-content {
|
|
89
|
-
display: flex;
|
|
90
|
-
position: absolute;
|
|
91
|
-
min-width: 1100px;
|
|
92
|
-
width: 100%;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.sdoc-editor-container.mobile .sdoc-editor-content.readonly.no-outline {
|
|
96
|
-
min-width: 100% !important;
|
|
97
|
-
width: 100% !important;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.sdoc-editor-container .sdoc-scroll-container {
|
|
101
|
-
z-index: 100;
|
|
102
|
-
overflow: auto;
|
|
103
|
-
height: 100%;
|
|
104
|
-
position: relative;
|
|
105
|
-
flex: 1;
|
|
106
|
-
background: #f5f5f5;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.sdoc-editor-container .sdoc-article-container {
|
|
110
|
-
position: relative;
|
|
111
|
-
top: 0;
|
|
112
|
-
width: 794px;
|
|
113
|
-
margin: 0 auto;
|
|
114
|
-
padding-top: 20px;
|
|
115
|
-
padding-bottom: 20px;
|
|
116
|
-
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/* List */
|
|
2
|
-
.sdoc-editor-container .comment-editor .list-container {
|
|
3
|
-
padding-left: 2em !important;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
1
|
.comment-editor .list-container li p {
|
|
7
2
|
margin: 0 !important;
|
|
8
3
|
}
|
|
@@ -14,6 +9,6 @@
|
|
|
14
9
|
}
|
|
15
10
|
|
|
16
11
|
/* Image */
|
|
17
|
-
.comment-editor .sdoc-image-wrapper
|
|
12
|
+
.comment-editor .sdoc-image-wrapper {
|
|
18
13
|
padding: 1px !important;
|
|
19
14
|
}
|
|
@@ -152,8 +152,10 @@ const updateImage = (editor, data) => {
|
|
|
152
152
|
};
|
|
153
153
|
exports.updateImage = updateImage;
|
|
154
154
|
const getImageURL = (data, editor) => {
|
|
155
|
+
console.log('data', data);
|
|
155
156
|
const {
|
|
156
157
|
src: url,
|
|
158
|
+
is_upload,
|
|
157
159
|
column_key
|
|
158
160
|
} = data;
|
|
159
161
|
if (column_key) {
|
|
@@ -174,12 +176,13 @@ const getImageURL = (data, editor) => {
|
|
|
174
176
|
}
|
|
175
177
|
|
|
176
178
|
// upload image | drag drop image | cut image
|
|
177
|
-
if (isImageUrlIsFromUpload(url)) return url;
|
|
179
|
+
if (isImageUrlIsFromUpload(url, is_upload)) return url;
|
|
178
180
|
|
|
179
181
|
// copy from others doc
|
|
180
|
-
if (isImageUrlIsFromCopy(url)) return url;
|
|
182
|
+
if (isImageUrlIsFromCopy(url, is_upload)) return url;
|
|
181
183
|
const serviceUrl = _context.default.getSetting('serviceUrl');
|
|
182
184
|
const assetsUrl = _context.default.getSetting('assetsUrl');
|
|
185
|
+
console.log(111, (0, _urlJoin.default)(serviceUrl, assetsUrl, url));
|
|
183
186
|
return (0, _urlJoin.default)(serviceUrl, assetsUrl, url);
|
|
184
187
|
};
|
|
185
188
|
exports.getImageURL = getImageURL;
|
|
@@ -301,14 +304,15 @@ const handleBase64Image = (editor, path, imgData) => {
|
|
|
301
304
|
});
|
|
302
305
|
};
|
|
303
306
|
exports.handleBase64Image = handleBase64Image;
|
|
304
|
-
const isImageUrlIsFromCopy = (url,
|
|
305
|
-
if (
|
|
307
|
+
const isImageUrlIsFromCopy = (url, is_upload) => {
|
|
308
|
+
if (is_upload) return false;
|
|
306
309
|
if (url && url.startsWith('http')) return true;
|
|
307
310
|
if (url && url.startsWith('attachment')) return true; // from yuque
|
|
308
311
|
return false;
|
|
309
312
|
};
|
|
310
313
|
exports.isImageUrlIsFromCopy = isImageUrlIsFromCopy;
|
|
311
|
-
const isImageUrlIsFromUpload = url => {
|
|
314
|
+
const isImageUrlIsFromUpload = (url, is_upload) => {
|
|
315
|
+
if (url && is_upload) return true;
|
|
312
316
|
if (url && url.startsWith('blob:http')) return true;
|
|
313
317
|
return false;
|
|
314
318
|
};
|
|
@@ -218,10 +218,10 @@ const Image = _ref => {
|
|
|
218
218
|
}
|
|
219
219
|
}, [data, editor]);
|
|
220
220
|
const onImageLoaded = (0, _react.useCallback)(() => {
|
|
221
|
-
if ((0, _helpers.isImageUrlIsFromCopy)(data.src, data === null || data === void 0 ? void 0 : data.
|
|
221
|
+
if ((0, _helpers.isImageUrlIsFromCopy)(data.src, data === null || data === void 0 ? void 0 : data.is_upload)) {
|
|
222
222
|
setCopyImageLoading(true);
|
|
223
223
|
}
|
|
224
|
-
}, [data.src, data === null || data === void 0 ? void 0 : data.
|
|
224
|
+
}, [data.src, data === null || data === void 0 ? void 0 : data.is_upload, setCopyImageLoading]);
|
|
225
225
|
const onImageLoadError = (0, _react.useCallback)(() => {
|
|
226
226
|
// Check is due to the image is pasted from the clipboard in base64
|
|
227
227
|
if (data.src.startsWith('data:image/jpeg;base64')) {
|
|
@@ -249,6 +249,7 @@ const Image = _ref => {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
}, [data, editor, element]);
|
|
252
|
+
console.log(isCopyImageLoading, isUploadLoading);
|
|
252
253
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isShowImagePlaceholder && /*#__PURE__*/_react.default.createElement("span", Object.assign({
|
|
253
254
|
className: (0, _classnames.default)('sdoc-image-wrapper', className)
|
|
254
255
|
}, attributes, {
|
|
@@ -39,10 +39,11 @@ const useCopyImage = _ref => {
|
|
|
39
39
|
const [isCopyError, setIsCopyError] = (0, _react.useState)(is_copy_error);
|
|
40
40
|
(0, _react.useEffect)(() => {
|
|
41
41
|
const {
|
|
42
|
-
src: url
|
|
42
|
+
src: url,
|
|
43
|
+
is_upload
|
|
43
44
|
} = data;
|
|
44
45
|
if (isCopyError) return;
|
|
45
|
-
if (!(0, _helpers.isImageUrlIsFromCopy)(url)) return;
|
|
46
|
+
if (!(0, _helpers.isImageUrlIsFromCopy)(url, is_upload)) return;
|
|
46
47
|
const downloadAndUploadImages = async url => {
|
|
47
48
|
try {
|
|
48
49
|
const response = await fetch(url);
|
|
@@ -11,12 +11,12 @@ var _slateReact = require("@seafile/slate-react");
|
|
|
11
11
|
var _context = _interopRequireDefault(require("../../../context"));
|
|
12
12
|
var _helpers = require("./helpers");
|
|
13
13
|
var _imageCache = _interopRequireDefault(require("./image-cache"));
|
|
14
|
-
const updateImageNode = async (editor, element, newUrl
|
|
14
|
+
const updateImageNode = async (editor, element, newUrl) => {
|
|
15
15
|
const nodePath = _slateReact.ReactEditor.findPath(editor, element);
|
|
16
16
|
const newData = {
|
|
17
|
-
src: newUrl
|
|
17
|
+
src: newUrl,
|
|
18
|
+
is_upload: true
|
|
18
19
|
};
|
|
19
|
-
uploadFromDtable && (newData['upload_from_dtable'] = true);
|
|
20
20
|
_slate.Transforms.setNodes(editor, {
|
|
21
21
|
data: newData
|
|
22
22
|
}, {
|
|
@@ -45,8 +45,7 @@ const useUploadImage = _ref => {
|
|
|
45
45
|
const fileItem = _imageCache.default.getImage(file_uuid);
|
|
46
46
|
const imageUrl = await _context.default.api.uploadLocalImage([fileItem]);
|
|
47
47
|
if (imageUrl && imageUrl[0]) {
|
|
48
|
-
|
|
49
|
-
updateImageNode(editor, element, imageUrl[0], uploadFromDtable);
|
|
48
|
+
updateImageNode(editor, element, imageUrl[0]);
|
|
50
49
|
}
|
|
51
50
|
} catch (error) {
|
|
52
51
|
console.error(error.message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seafile/comment-editor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a comment editor",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
"fs-extra": "^10.0.0",
|
|
102
102
|
"html-webpack-plugin": "^5.5.0",
|
|
103
103
|
"husky": "8.0.3",
|
|
104
|
-
"i18next": "
|
|
105
|
-
"i18next-browser-languagedetector": "
|
|
104
|
+
"i18next": "^25.2.1",
|
|
105
|
+
"i18next-browser-languagedetector": "^8.1.0",
|
|
106
106
|
"i18next-http-backend": "^3.0.2",
|
|
107
107
|
"identity-obj-proxy": "^3.0.0",
|
|
108
108
|
"is-wsl": "^1.1.0",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"react-app-polyfill": "^3.0.0",
|
|
128
128
|
"react-dev-utils": "^12.0.1",
|
|
129
129
|
"react-dom": "18.3.1",
|
|
130
|
-
"react-i18next": "
|
|
130
|
+
"react-i18next": "^15.5.2",
|
|
131
131
|
"react-refresh": "^0.11.0",
|
|
132
132
|
"react-router": "7.5.2",
|
|
133
133
|
"react-router-dom": "7.1.3",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
.sdoc-editor-container .sdoc-editor-content.no-outline .sdoc-article-container {
|
|
2
|
-
margin-left: 0 !important;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.sdoc-editor-container.mobile .sdoc-editor-content.readonly .sdoc-article-container {
|
|
6
|
-
padding: 0;
|
|
7
|
-
width: 100% !important;
|
|
8
|
-
min-width: 100% !important;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.sdoc-editor-container.mobile .sdoc-editor-content.readonly .article {
|
|
12
|
-
width: 100vw !important;
|
|
13
|
-
padding: 1rem;
|
|
14
|
-
}
|