@seafile/comment-editor 0.0.1-alpha.81 → 0.0.1-alpha.82

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.
@@ -304,7 +304,8 @@ const handleBase64Image = (editor, path, imgData) => {
304
304
  });
305
305
  };
306
306
  exports.handleBase64Image = handleBase64Image;
307
- const isImageUrlIsFromCopy = url => {
307
+ const isImageUrlIsFromCopy = (url, uploadFromDtable) => {
308
+ if (uploadFromDtable) return false;
308
309
  if (url && url.startsWith('http')) return true;
309
310
  if (url && url.startsWith('attachment')) return true; // from yuque
310
311
  return false;
@@ -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)) {
221
+ if ((0, _helpers.isImageUrlIsFromCopy)(data.src, data === null || data === void 0 ? void 0 : data.upload_from_dtable)) {
222
222
  setCopyImageLoading(true);
223
223
  }
224
- }, [data.src, setCopyImageLoading]);
224
+ }, [data.src, data === null || data === void 0 ? void 0 : data.upload_from_dtable, 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')) {
@@ -11,11 +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, uploadFromDtable) => {
15
15
  const nodePath = _slateReact.ReactEditor.findPath(editor, element);
16
16
  const newData = {
17
17
  src: newUrl
18
18
  };
19
+ uploadFromDtable && (newData['upload_from_dtable'] = true);
19
20
  _slate.Transforms.setNodes(editor, {
20
21
  data: newData
21
22
  }, {
@@ -45,7 +46,8 @@ const useUploadImage = _ref => {
45
46
  const imageUrl = await _context.default.api.uploadLocalImage([fileItem]);
46
47
  console.log('imageUrl', imageUrl);
47
48
  if (imageUrl && imageUrl[0]) {
48
- updateImageNode(editor, element, imageUrl[0]);
49
+ const uploadFromDtable = imageUrl !== null && imageUrl !== void 0 && imageUrl.upload_from_dtable ? true : false;
50
+ updateImageNode(editor, element, imageUrl[0], uploadFromDtable);
49
51
  }
50
52
  } catch (error) {
51
53
  console.error(error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/comment-editor",
3
- "version": "0.0.1-alpha.81",
3
+ "version": "0.0.1-alpha.82",
4
4
  "private": false,
5
5
  "description": "This is a comment editor",
6
6
  "main": "dist/index.js",