@seafile/sdoc-editor 0.1.174 → 0.1.175

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.
@@ -133,6 +133,12 @@ var SeafileAPI = /*#__PURE__*/function () {
133
133
  files_url: filesUrl
134
134
  });
135
135
  }
136
+ }, {
137
+ key: "getCopyMoveProgressView",
138
+ value: function getCopyMoveProgressView(docUuid, taskId) {
139
+ var url = 'api/v2.1/seadoc/query-copy-move-progress/' + docUuid + '/?&doc_uuid=' + docUuid + '&task_id=' + taskId;
140
+ return this.req.get(url);
141
+ }
136
142
  }]);
137
143
  return SeafileAPI;
138
144
  }();
@@ -4,7 +4,8 @@ export var INTERNAL_EVENT = {
4
4
  HIDDEN_CODE_BLOCK_HOVER_MENU: 'hidden_code_block_hover_menu',
5
5
  ON_MOUSE_ENTER_BLOCK: 'on_mouse_enter_block',
6
6
  INSERT_ELEMENT: 'insert_element',
7
- OUTLINE_STATE_CHANGED: 'outline_state_changed'
7
+ OUTLINE_STATE_CHANGED: 'outline_state_changed',
8
+ RELOAD_IMAGE: 'reload_image'
8
9
  };
9
10
  export var PAGE_EDIT_AREA_WIDTH = 672; // 672 = 794 - 2[borderLeft + borderRight] - 120[paddingLeft + paddingRight]
10
11
 
@@ -140,7 +140,8 @@ var EditableArticle = function EditableArticle(_ref) {
140
140
  onKeyDown: onKeyDown,
141
141
  onMouseDown: onMouseDown,
142
142
  decorate: decorate,
143
- onCut: eventProxy.onCut
143
+ onCut: eventProxy.onCut,
144
+ onCopy: eventProxy.onCopy
144
145
  })), /*#__PURE__*/React.createElement(SideToolbar, null), isShowComment && /*#__PURE__*/React.createElement(CommentContextProvider, null, /*#__PURE__*/React.createElement(CommentWrapper, null))));
145
146
  };
146
147
  EditableArticle.defaultProps = {
@@ -12,6 +12,7 @@ export var HEADERS = [HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6];
12
12
  export var HEADER_TITLE_MAP = (_HEADER_TITLE_MAP = {}, _defineProperty(_HEADER_TITLE_MAP, TITLE, 'Title'), _defineProperty(_HEADER_TITLE_MAP, SUBTITLE, 'Subtitle'), _defineProperty(_HEADER_TITLE_MAP, HEADER1, 'Header_one'), _defineProperty(_HEADER_TITLE_MAP, HEADER2, 'Header_two'), _defineProperty(_HEADER_TITLE_MAP, HEADER3, 'Header_three'), _defineProperty(_HEADER_TITLE_MAP, HEADER4, 'Header_four'), _defineProperty(_HEADER_TITLE_MAP, HEADER5, 'Header_five'), _defineProperty(_HEADER_TITLE_MAP, HEADER6, 'Header_six'), _defineProperty(_HEADER_TITLE_MAP, PARAGRAPH, 'Paragraph'), _HEADER_TITLE_MAP);
13
13
  export var TRANSPARENT = 'transparent';
14
14
  export var CLIPBOARD_FORMAT_KEY = 'x-slate-fragment';
15
+ export var CLIPBOARD_ORIGIN_SDOC_KEY = 'origin-sdoc-uuid';
15
16
  export var INSERT_FILE_DISPLAY_TYPE = ['text_link', 'icon_link', 'card_link'];
16
17
  export var INSERT_POSITION = {
17
18
  BEFORE: 'before',
@@ -1,11 +1,15 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
5
  import urlJoin from 'url-join';
4
6
  import { Editor, Range, Transforms, Path } from '@seafile/slate';
5
7
  import { ReactEditor } from '@seafile/slate-react';
6
- import { CODE_BLOCK, ELEMENT_TYPE, IMAGE, INSERT_POSITION, LIST_ITEM } from '../../constants';
7
- import { generateEmptyElement, getNodeType, isTextNode, getParentNode } from '../../core';
8
8
  import context from '../../../../context';
9
+ import EventBus from '../../../utils/event-bus';
10
+ import { generateEmptyElement, getNodeType, isTextNode, getParentNode } from '../../core';
11
+ import { INTERNAL_EVENT } from '../../../constants';
12
+ import { CODE_BLOCK, ELEMENT_TYPE, IMAGE, INSERT_POSITION, LIST_ITEM } from '../../constants';
9
13
  export var isInsertImageMenuDisabled = function isInsertImageMenuDisabled(editor, readonly) {
10
14
  if (readonly) return true;
11
15
  var selection = editor.selection;
@@ -32,11 +36,9 @@ export var isInsertImageMenuDisabled = function isInsertImageMenuDisabled(editor
32
36
  };
33
37
  export var generateImageNode = function generateImageNode(src) {
34
38
  var element = generateEmptyElement(IMAGE);
35
- var docUuid = context.getSetting('docUuid');
36
39
  return _objectSpread(_objectSpread({}, element), {}, {
37
40
  data: {
38
- src: src,
39
- origin_doc_uuid: docUuid
41
+ src: src
40
42
  }
41
43
  });
42
44
  };
@@ -86,4 +88,61 @@ export var getImageURL = function getImageURL(url) {
86
88
  var serviceUrl = context.getSetting('serviceUrl');
87
89
  var assetsUrl = context.getSetting('assetsUrl');
88
90
  return urlJoin(serviceUrl, assetsUrl, url);
91
+ };
92
+ export var hasSdocImages = function hasSdocImages(originSdocUuid, fragmentData) {
93
+ var sdocUuid = context.getSetting('docUuid');
94
+ var hasImg = fragmentData.some(function (item) {
95
+ return item.children.some(function (child) {
96
+ return (child === null || child === void 0 ? void 0 : child.type) === IMAGE;
97
+ });
98
+ });
99
+ return originSdocUuid !== sdocUuid && hasImg;
100
+ };
101
+ export var getImageData = function getImageData(fragmentData) {
102
+ var imageData = new Set();
103
+ fragmentData.forEach(function (item) {
104
+ return item.children.forEach(function (child) {
105
+ if ((child === null || child === void 0 ? void 0 : child.type) === IMAGE && !child.data.src.startsWith('http')) {
106
+ imageData.add(child.data.src.slice(1));
107
+ }
108
+ });
109
+ });
110
+ return Array.from(imageData);
111
+ };
112
+ export var queryCopyMoveProgressView = function queryCopyMoveProgressView(taskId) {
113
+ var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 300;
114
+ var timer;
115
+ var stop = function stop() {
116
+ clearTimeout(timer);
117
+ };
118
+ var start = /*#__PURE__*/function () {
119
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
120
+ var res, done, eventBus;
121
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
122
+ while (1) switch (_context.prev = _context.next) {
123
+ case 0:
124
+ _context.next = 2;
125
+ return context.getCopyMoveProgressView(taskId);
126
+ case 2:
127
+ res = _context.sent;
128
+ done = res.data.done;
129
+ if (done) {
130
+ stop();
131
+ // Reload image
132
+ eventBus = EventBus.getInstance();
133
+ eventBus.dispatch(INTERNAL_EVENT.RELOAD_IMAGE);
134
+ } else {
135
+ timer = setTimeout(start, interval);
136
+ }
137
+ case 5:
138
+ case "end":
139
+ return _context.stop();
140
+ }
141
+ }, _callee);
142
+ }));
143
+ return function start() {
144
+ return _ref.apply(this, arguments);
145
+ };
146
+ }();
147
+ start();
89
148
  };
@@ -1,9 +1,12 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { Transforms, Path, Editor, Element } from '@seafile/slate';
3
+ import toaster from '../../../../components/toast';
3
4
  import context from '../../../../context';
4
- import { insertImage, copyImage } from './helpers';
5
+ import { insertImage, hasSdocImages, getImageData, queryCopyMoveProgressView } from './helpers';
5
6
  import { focusEditor } from '../../core';
6
- import { INSERT_POSITION, CLIPBOARD_FORMAT_KEY } from '../../constants';
7
+ import { getErrorMsg } from '../../../../utils';
8
+ import { getSlateFragmentAttribute } from '../../../utils/document-utils';
9
+ import { INSERT_POSITION, CLIPBOARD_FORMAT_KEY, CLIPBOARD_ORIGIN_SDOC_KEY, IMAGE } from '../../constants';
7
10
  var withImage = function withImage(editor) {
8
11
  var isInline = editor.isInline,
9
12
  isVoid = editor.isVoid,
@@ -14,7 +17,7 @@ var withImage = function withImage(editor) {
14
17
  // rewrite isInline
15
18
  newEditor.isInline = function (elem) {
16
19
  var type = elem.type;
17
- if (type === 'image') {
20
+ if (type === IMAGE) {
18
21
  return true;
19
22
  }
20
23
  return isInline(elem);
@@ -23,13 +26,30 @@ var withImage = function withImage(editor) {
23
26
  // rewrite isVoid
24
27
  newEditor.isVoid = function (elem) {
25
28
  var type = elem.type;
26
- if (type === 'image') {
29
+ if (type === IMAGE) {
27
30
  return true;
28
31
  }
29
32
  return isVoid(elem);
30
33
  };
31
34
  newEditor.insertData = function (data) {
32
- if (data.types && data.types.includes('Files') && data.files[0].type.includes('image')) {
35
+ var fragment = data.getData("application/".concat(CLIPBOARD_FORMAT_KEY)) || getSlateFragmentAttribute(data);
36
+ var originSdocUuid = data.getData("text/".concat(CLIPBOARD_ORIGIN_SDOC_KEY));
37
+ if (fragment && originSdocUuid) {
38
+ var decoded = decodeURIComponent(window.atob(fragment));
39
+ var fragmentData = JSON.parse(decoded);
40
+ if (hasSdocImages(originSdocUuid, fragmentData)) {
41
+ var imageData = getImageData(fragmentData);
42
+ context.copyImage(originSdocUuid, imageData).then(function (res) {
43
+ if (res.status === 200) {
44
+ queryCopyMoveProgressView(res.data.task_id);
45
+ }
46
+ }).catch(function (error) {
47
+ var errorMessage = getErrorMsg(error);
48
+ toaster.danger(errorMessage);
49
+ });
50
+ }
51
+ }
52
+ if (data.types && data.types.includes('Files') && data.files[0].type.includes(IMAGE)) {
33
53
  context.uploadLocalImage(data.files[0]).then(function (fileUrl) {
34
54
  insertImage(newEditor, fileUrl, editor.selection, INSERT_POSITION.CURRENT);
35
55
  });
@@ -65,7 +85,7 @@ var withImage = function withImage(editor) {
65
85
  _Editor$parent2 = _slicedToArray(_Editor$parent, 2),
66
86
  node = _Editor$parent2[0],
67
87
  path = _Editor$parent2[1];
68
- if (Element.isElement(node) && node.type === 'image') {
88
+ if (Element.isElement(node) && node.type === IMAGE) {
69
89
  focusEditor(editor, Path.next(path));
70
90
  }
71
91
  };
@@ -3,18 +3,16 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- import { ReactEditor, useSelected } from '@seafile/slate-react';
7
- import { Transforms } from '@seafile/slate';
6
+ import { useSelected } from '@seafile/slate-react';
8
7
  import React from 'react';
9
8
  import classNames from 'classnames';
10
9
  import { withTranslation } from 'react-i18next';
11
10
  import { getImageURL, updateImage } from './helpers';
12
11
  import ImagePreviewer from './dialogs/image-previewer';
13
- import toaster from '../../../../components/toast';
14
- import context from '../../../../context';
15
- import { getErrorMsg } from '../../../../utils';
16
- import imagePlaceholder from '../../../assets/images/image-placeholder.png';
12
+ import EventBus from '../../../utils/event-bus';
13
+ import { INTERNAL_EVENT } from '../../../constants';
17
14
  import { ADDED_STYLE, DELETED_STYLE } from '../../constants';
15
+ import imagePlaceholder from '../../../assets/images/image-placeholder.png';
18
16
  var Image = /*#__PURE__*/function (_React$Component) {
19
17
  _inherits(Image, _React$Component);
20
18
  var _super = _createSuper(Image);
@@ -85,6 +83,24 @@ var Image = /*#__PURE__*/function (_React$Component) {
85
83
  _this.setResizerRef = function (ref) {
86
84
  _this.resizer = ref;
87
85
  };
86
+ _this.reloadImage = function () {
87
+ if (_this.image) {
88
+ var data = _this.props.element.data;
89
+ _this.image.src = getImageURL(data.src);
90
+ }
91
+ };
92
+ _this.onImageLoadError = function () {
93
+ _this.setState({
94
+ isShowImagePlaceholder: true
95
+ });
96
+ var element = _this.props.element;
97
+ var data = element.data;
98
+ // External network images do not reload after failure to load
99
+ if (!data.src.startsWith('http')) {
100
+ var eventBus = EventBus.getInstance();
101
+ eventBus.subscribe(INTERNAL_EVENT.RELOAD_IMAGE, _this.reloadImage);
102
+ }
103
+ };
88
104
  _this.state = {
89
105
  width: null,
90
106
  isResizing: false,
@@ -94,54 +110,15 @@ var Image = /*#__PURE__*/function (_React$Component) {
94
110
  return _this;
95
111
  }
96
112
  _createClass(Image, [{
97
- key: "componentDidMount",
98
- value: function componentDidMount() {
99
- var _this2 = this;
100
- var docUuid = context.getSetting('docUuid');
101
- var _this$props2 = this.props,
102
- element = _this$props2.element,
103
- editor = _this$props2.editor;
104
- var data = element.data;
105
- var origin_doc_uuid = data.origin_doc_uuid,
106
- src = data.src;
107
-
108
- // Pictures are copied from other documents
109
- if (origin_doc_uuid && origin_doc_uuid !== docUuid) {
110
- this.setState({
111
- isShowImagePlaceholder: true
112
- });
113
- var originDocUuid = origin_doc_uuid;
114
- var imageList = [src.slice(1)];
115
- context.copyImage(originDocUuid, imageList).then(function (res) {
116
- if (res.status === 200) {
117
- var path = ReactEditor.findPath(editor, element);
118
- Transforms.setNodes(editor, {
119
- data: _objectSpread(_objectSpread({}, data), {}, {
120
- origin_doc_uuid: docUuid
121
- })
122
- }, {
123
- at: path
124
- });
125
- _this2.setState({
126
- isShowImagePlaceholder: false
127
- });
128
- }
129
- }).catch(function (error) {
130
- var errorMessage = getErrorMsg(error);
131
- toaster.danger(errorMessage);
132
- });
133
- }
134
- }
135
- }, {
136
113
  key: "render",
137
114
  value: function render() {
138
- var _this$props3 = this.props,
139
- className = _this$props3.className,
140
- attributes = _this$props3.attributes,
141
- element = _this$props3.element,
142
- children = _this$props3.children,
143
- isSelected = _this$props3.isSelected,
144
- t = _this$props3.t;
115
+ var _this$props2 = this.props,
116
+ className = _this$props2.className,
117
+ attributes = _this$props2.attributes,
118
+ element = _this$props2.element,
119
+ children = _this$props2.children,
120
+ isSelected = _this$props2.isSelected,
121
+ t = _this$props2.t;
145
122
  var _this$state = this.state,
146
123
  isResizing = _this$state.isResizing,
147
124
  isShowImagePreview = _this$state.isShowImagePreview,
@@ -163,6 +140,7 @@ var Image = /*#__PURE__*/function (_React$Component) {
163
140
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", Object.assign({
164
141
  className: classNames('sdoc-image-wrapper', className)
165
142
  }, attributes), /*#__PURE__*/React.createElement("img", {
143
+ onError: this.onImageLoadError,
166
144
  className: imageClassName,
167
145
  ref: this.setImageRef,
168
146
  src: getImageURL(data.src),
@@ -1,14 +1,6 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import { decorateOperation, replacePastedDataId } from './helpers';
2
+ import { getSlateFragmentAttribute } from '../utils/document-utils';
3
3
  import { CLIPBOARD_FORMAT_KEY } from '../extension/constants';
4
- var catchSlateFragment = /data-slate-fragment="(.+?)"/m;
5
- var getSlateFragmentAttribute = function getSlateFragmentAttribute(dataTransfer) {
6
- var htmlData = dataTransfer.getData('text/html');
7
- var _ref = htmlData.match(catchSlateFragment) || [],
8
- _ref2 = _slicedToArray(_ref, 2),
9
- fragment = _ref2[1];
10
- return fragment;
11
- };
12
4
  var withNodeId = function withNodeId(editor) {
13
5
  var apply = editor.apply;
14
6
  var newEditor = editor;
@@ -1,5 +1,8 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
1
2
  import ObjectUtils from './object-utils';
3
+ import context from '../../context';
2
4
  import { generateDefaultText } from '../../basic-sdk/extension/core/utils/index';
5
+ import { CLIPBOARD_ORIGIN_SDOC_KEY } from '../extension/constants';
3
6
  export var normalizeChildren = function normalizeChildren(children) {
4
7
  // text
5
8
  if (!Array.isArray(children)) return children;
@@ -15,4 +18,16 @@ export var normalizeChildren = function normalizeChildren(children) {
15
18
  child.children = normalizeChildren(child.children);
16
19
  return child;
17
20
  });
21
+ };
22
+ export var setOriginSdocKey = function setOriginSdocKey(event) {
23
+ var docUuid = context.getSetting('docUuid');
24
+ event.clipboardData.setData("text/".concat(CLIPBOARD_ORIGIN_SDOC_KEY), docUuid);
25
+ };
26
+ export var getSlateFragmentAttribute = function getSlateFragmentAttribute(dataTransfer) {
27
+ var catchSlateFragment = /data-slate-fragment="(.+?)"/m;
28
+ var htmlData = dataTransfer.getData('text/html');
29
+ var _ref = htmlData.match(catchSlateFragment) || [],
30
+ _ref2 = _slicedToArray(_ref, 2),
31
+ fragment = _ref2[1];
32
+ return fragment;
18
33
  };
@@ -3,6 +3,7 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import isHotkey from 'is-hotkey';
4
4
  import EventBus from '../utils/event-bus';
5
5
  import { getSelectedNodeByType } from '../extension/core/queries/';
6
+ import { setOriginSdocKey } from './document-utils';
6
7
  import { ELEMENT_TYPE } from '../extension/constants';
7
8
  import { INTERNAL_EVENT } from '../constants';
8
9
  var EventProxy = /*#__PURE__*/_createClass(function EventProxy(_editor) {
@@ -79,11 +80,10 @@ var EventProxy = /*#__PURE__*/_createClass(function EventProxy(_editor) {
79
80
  }
80
81
  };
81
82
  this.onCopy = function (event) {
82
- event.stopPropagation();
83
- event.nativeEvent.stopImmediatePropagation();
84
- // 处理数据
83
+ setOriginSdocKey(event);
85
84
  };
86
85
  this.onCut = function (event) {
86
+ setOriginSdocKey(event);
87
87
  if (_this.editor.cut) {
88
88
  _this.editor.cut(event);
89
89
  }
package/dist/context.js CHANGED
@@ -242,6 +242,12 @@ var Context = /*#__PURE__*/function () {
242
242
  var docUuid = this.getSetting('docUuid');
243
243
  return this.api.getLinkFilesInfo(docUuid, filesUrl);
244
244
  }
245
+ }, {
246
+ key: "getCopyMoveProgressView",
247
+ value: function getCopyMoveProgressView(taskId) {
248
+ var docUuid = this.getSetting('docUuid');
249
+ return this.api.getCopyMoveProgressView(docUuid, taskId);
250
+ }
245
251
  }]);
246
252
  return Context;
247
253
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.174",
3
+ "version": "0.1.175",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",