@seafile/sdoc-editor 0.1.173 → 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.
Files changed (29) hide show
  1. package/dist/api/seafile-api.js +14 -0
  2. package/dist/basic-sdk/comment/comment/editor-comment.js +5 -2
  3. package/dist/basic-sdk/comment/comment/elements-comment-count/element-comment-count.js +40 -0
  4. package/dist/basic-sdk/comment/comment/elements-comment-count/index.css +29 -0
  5. package/dist/basic-sdk/comment/comment/elements-comment-count/index.js +24 -0
  6. package/dist/basic-sdk/comment/helper.js +18 -0
  7. package/dist/basic-sdk/constants/index.js +2 -1
  8. package/dist/basic-sdk/editor/editable-article.js +2 -1
  9. package/dist/basic-sdk/extension/constants/index.js +1 -0
  10. package/dist/basic-sdk/extension/core/queries/index.js +24 -0
  11. package/dist/basic-sdk/extension/plugins/image/helpers.js +64 -5
  12. package/dist/basic-sdk/extension/plugins/image/plugin.js +26 -6
  13. package/dist/basic-sdk/extension/plugins/image/render-elem.js +30 -52
  14. package/dist/basic-sdk/extension/plugins/link/dialog/add-link-dialog/index.js +5 -7
  15. package/dist/basic-sdk/extension/plugins/link/helpers.js +9 -1
  16. package/dist/basic-sdk/extension/plugins/link/plugin.js +30 -9
  17. package/dist/basic-sdk/extension/render/render-element.js +0 -15
  18. package/dist/basic-sdk/extension/utils/index.js +3 -0
  19. package/dist/basic-sdk/node-id/index.js +1 -9
  20. package/dist/basic-sdk/utils/document-utils.js +15 -0
  21. package/dist/basic-sdk/utils/event-handler.js +3 -3
  22. package/dist/context.js +12 -0
  23. package/package.json +4 -6
  24. package/public/media/sdoc-editor-font/iconfont.eot +0 -0
  25. package/public/media/sdoc-editor-font/iconfont.svg +4 -2
  26. package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
  27. package/public/media/sdoc-editor-font/iconfont.woff +0 -0
  28. package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
  29. package/public/media/sdoc-editor-font.css +14 -10
@@ -125,6 +125,20 @@ var SeafileAPI = /*#__PURE__*/function () {
125
125
  image_list: imageList
126
126
  });
127
127
  }
128
+ }, {
129
+ key: "getLinkFilesInfo",
130
+ value: function getLinkFilesInfo(docUuid, filesUrl) {
131
+ var url = '/api/v2.1/seadoc/files-info/' + docUuid + '/';
132
+ return this.req.post(url, {
133
+ files_url: filesUrl
134
+ });
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
+ }
128
142
  }]);
129
143
  return SeafileAPI;
130
144
  }();
@@ -7,6 +7,7 @@ import { useCursorPosition } from '../helper';
7
7
  import CommentList from './comment-list';
8
8
  import { useSelectionElement } from '../../hooks/use-selection-element';
9
9
  import { useCommentContext } from '../hooks/use-comment-context';
10
+ import ElementsCommentCount from './elements-comment-count';
10
11
  var EditorComment = function EditorComment() {
11
12
  useSelectionUpdate();
12
13
  var editor = useSlateStatic();
@@ -82,8 +83,10 @@ var EditorComment = function EditorComment() {
82
83
  className: "add-comment-icon",
83
84
  onClick: onAddCommentToggle
84
85
  }, /*#__PURE__*/React.createElement("i", {
85
- className: "sdocfont sdoc-comment mr-1"
86
- }))), /*#__PURE__*/React.createElement("div", {
86
+ className: "sdocfont sdoc-add-comment mr-1"
87
+ }))), /*#__PURE__*/React.createElement(ElementsCommentCount, {
88
+ elementCommentsMap: element_comments_map
89
+ }), /*#__PURE__*/React.createElement("div", {
87
90
  className: "comment-list-wrapper",
88
91
  style: isShowComments ? {
89
92
  width: '294px'
@@ -0,0 +1,40 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useSlateStatic } from '@seafile/slate-react';
3
+ import { Editor } from '@seafile/slate';
4
+ import { getNodeById, focusEditor, findPath } from '../../../extension/core';
5
+ import { useScrollContext } from '../../../hooks/use-scroll-context';
6
+ import { getElementCommentCountTop } from '../../helper';
7
+ import { eventStopPropagation } from '../../../utils/mouse-event';
8
+ var ElementCommentCount = function ElementCommentCount(_ref) {
9
+ var _scrollRef$current;
10
+ var elementId = _ref.elementId,
11
+ commentsCount = _ref.commentsCount;
12
+ var editor = useSlateStatic();
13
+ var element = getNodeById(editor.children, elementId);
14
+ var scrollRef = useScrollContext();
15
+ var onClick = useCallback(function (event) {
16
+ eventStopPropagation(event);
17
+ var path = findPath(editor, element);
18
+ var endOfFirstNode = Editor.end(editor, path);
19
+ var range = {
20
+ anchor: endOfFirstNode,
21
+ focus: endOfFirstNode
22
+ };
23
+ focusEditor(editor, range);
24
+ }, [editor, element]);
25
+ if (!element) return null;
26
+ var scrollTop = (scrollRef === null || scrollRef === void 0 ? void 0 : (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.scrollTop) || 0;
27
+ var top = getElementCommentCountTop(editor, element, scrollTop);
28
+ return /*#__PURE__*/React.createElement("div", {
29
+ className: "element-comments-count",
30
+ style: {
31
+ top: top
32
+ },
33
+ onClick: onClick
34
+ }, /*#__PURE__*/React.createElement("i", {
35
+ className: "sdocfont sdoc-comment-count"
36
+ }), /*#__PURE__*/React.createElement("div", {
37
+ className: "element-comments-count-value"
38
+ }, commentsCount));
39
+ };
40
+ export default ElementCommentCount;
@@ -0,0 +1,29 @@
1
+ .sdoc-comment-container .comment-container-right .element-comments-count {
2
+ position: absolute;
3
+ left: -22px;
4
+ height: 16px;
5
+ width: 16px;
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ color: #999;
10
+ }
11
+
12
+ .sdoc-comment-container .comment-container-right .element-comments-count:hover {
13
+ color: #333;
14
+ cursor: pointer;
15
+ }
16
+
17
+ .sdoc-comment-container .comment-container-right .element-comments-count-value {
18
+ width: 16px;
19
+ height: 14px;
20
+ position: absolute;
21
+ left: 0;
22
+ top: 0;
23
+ cursor: pointer;
24
+ pointer-events: none;
25
+ font-size: 12px;
26
+ color: #fff;
27
+ line-height: 13px;
28
+ text-align: center;
29
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import ElementCommentCount from './element-comment-count';
3
+ import './index.css';
4
+ var ElementsCommentCount = function ElementsCommentCount(_ref) {
5
+ var elementCommentsMap = _ref.elementCommentsMap;
6
+ if (!elementCommentsMap) return null;
7
+ return /*#__PURE__*/React.createElement("div", {
8
+ className: "elements-comments-count"
9
+ }, Object.keys(elementCommentsMap).map(function (elementId) {
10
+ var comments = elementCommentsMap[elementId];
11
+ if (!Array.isArray(comments) || comments.length === 0) return null;
12
+ var unresolvedComment = comments.filter(function (item) {
13
+ return !item.resolved;
14
+ });
15
+ var unresolvedCommentCount = unresolvedComment.length;
16
+ if (unresolvedCommentCount === 0) return null;
17
+ return /*#__PURE__*/React.createElement(ElementCommentCount, {
18
+ key: elementId,
19
+ elementId: elementId,
20
+ commentsCount: unresolvedCommentCount
21
+ });
22
+ }));
23
+ };
24
+ export default ElementsCommentCount;
@@ -1,3 +1,4 @@
1
+ import { ReactEditor } from '@seafile/slate-react';
1
2
  import context from '../../context';
2
3
  import { useScrollContext } from '../hooks/use-scroll-context';
3
4
  export var getSelectionRange = function getSelectionRange() {
@@ -41,4 +42,21 @@ export var getAvatarUrl = function getAvatarUrl() {
41
42
  var server = context.getSetting('serviceUrl');
42
43
  var avatarUrl = "".concat(server, "/media/avatars/default.png");
43
44
  return avatarUrl;
45
+ };
46
+ export var getElementCommentCountTop = function getElementCommentCountTop(editor, element, scrollTop) {
47
+ var minY;
48
+ var children = element.children || [];
49
+ children.forEach(function (child) {
50
+ var childDom = ReactEditor.toDOMNode(editor, child);
51
+
52
+ // use child real dom
53
+ var childRealDom = childDom.childNodes[0];
54
+ var _ref2 = childRealDom ? childRealDom.getBoundingClientRect() : {
55
+ y: 0
56
+ },
57
+ y = _ref2.y;
58
+ if (!minY) minY = y;
59
+ minY = Math.min(minY, y);
60
+ });
61
+ return minY - 100 + scrollTop; // 100: header height(56) + toolbar height(44)
44
62
  };
@@ -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',
@@ -44,6 +44,30 @@ export var getNode = function getNode(editor, path) {
44
44
  export var getNodeType = function getNodeType(node) {
45
45
  return Element.isElement(node) ? node.type : '';
46
46
  };
47
+ export var getNodeById = function getNodeById(nodes, nodeId) {
48
+ var node;
49
+ for (var i = 0; i < nodes.length; i++) {
50
+ var currentNode = nodes[i];
51
+ if (currentNode.id === nodeId) {
52
+ node = currentNode;
53
+ break;
54
+ }
55
+ var childrenNodes = currentNode.children;
56
+ if (!Array.isArray(childrenNodes)) continue;
57
+ var childNode = childrenNodes.find(function (node) {
58
+ return node.id === nodeId;
59
+ });
60
+ if (childNode) {
61
+ node = childNode;
62
+ break;
63
+ }
64
+ childNode = getNodeById(childrenNodes, nodeId);
65
+ if (!childNode) continue;
66
+ node = childNode;
67
+ break;
68
+ }
69
+ return node;
70
+ };
47
71
  export var isTextNode = function isTextNode(node) {
48
72
  if (!node) return false;
49
73
  if (!ObjectUtils.hasProperty(node, 'children') && ObjectUtils.hasProperty(node, 'text')) return true;
@@ -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,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import React, { Fragment, useCallback, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Alert } from 'reactstrap';
4
+ import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Alert, Label } from 'reactstrap';
5
5
  import { insertLink, updateLink, checkLink } from '../../helpers';
6
6
  var AddLinkDialog = function AddLinkDialog(_ref) {
7
7
  var editor = _ref.editor,
@@ -89,9 +89,8 @@ var AddLinkDialog = function AddLinkDialog(_ref) {
89
89
  toggle: closeDialog
90
90
  }, t('Insert_link')), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
91
91
  className: "form-group"
92
- }, /*#__PURE__*/React.createElement("label", {
93
- className: "form-check-label",
94
- htmlFor: "addLink"
92
+ }, /*#__PURE__*/React.createElement(Label, {
93
+ for: "addLink"
95
94
  }, t('Link_address')), /*#__PURE__*/React.createElement("input", {
96
95
  onKeyDown: onKeyDown,
97
96
  autoFocus: true,
@@ -105,9 +104,8 @@ var AddLinkDialog = function AddLinkDialog(_ref) {
105
104
  className: "mt-2"
106
105
  }, t(linkErrorMessage))), /*#__PURE__*/React.createElement("div", {
107
106
  className: "form-group"
108
- }, /*#__PURE__*/React.createElement("label", {
109
- className: "form-check-label",
110
- htmlFor: "addTitle"
107
+ }, /*#__PURE__*/React.createElement(Label, {
108
+ for: "addTitle"
111
109
  }, t('Link_title')), /*#__PURE__*/React.createElement("input", {
112
110
  onKeyDown: onKeyDown,
113
111
  type: "text",
@@ -203,4 +203,12 @@ export var unWrapLinkNode = /*#__PURE__*/function () {
203
203
  return function unWrapLinkNode(_x) {
204
204
  return _ref3.apply(this, arguments);
205
205
  };
206
- }();
206
+ }();
207
+ export var isSdocFile = function isSdocFile(res, url) {
208
+ var files_info = res.data.files_info;
209
+ var fileInfo = files_info[url];
210
+ var _ref4 = fileInfo || {},
211
+ is_dir = _ref4.is_dir,
212
+ file_ext = _ref4.file_ext;
213
+ return !is_dir && file_ext === 'sdoc';
214
+ };
@@ -2,9 +2,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { Transforms, Node, Editor, Range } from '@seafile/slate';
3
3
  import slugid from 'slugid';
4
4
  import isUrl from 'is-url';
5
- import { genLinkNode } from './helpers';
5
+ import context from '../../../../context';
6
+ import { insertSdocFileLink } from '../sdoc-link/helpers';
7
+ import { genLinkNode, isSdocFile } from './helpers';
6
8
  import { getNodeType, getSelectedNodeByType } from '../../core';
7
- import { isImage } from '../../utils';
9
+ import { isImage, isSameDomain } from '../../utils';
10
+ import { LINK } from '../../constants';
8
11
  var withLink = function withLink(editor) {
9
12
  var normalizeNode = editor.normalizeNode,
10
13
  isInline = editor.isInline,
@@ -15,14 +18,14 @@ var withLink = function withLink(editor) {
15
18
  // Rewrite isInline
16
19
  newEditor.isInline = function (elem) {
17
20
  var type = elem.type;
18
- if (type === 'link') {
21
+ if (type === LINK) {
19
22
  return true;
20
23
  }
21
24
  return isInline(elem);
22
25
  };
23
26
  newEditor.insertText = function (text) {
24
27
  var path = Editor.path(editor, editor.selection);
25
- if (Range.isCollapsed(editor.selection) && getSelectedNodeByType(editor, 'link') && Editor.isEnd(editor, editor.selection.focus, path)) {
28
+ if (Range.isCollapsed(editor.selection) && getSelectedNodeByType(editor, LINK) && Editor.isEnd(editor, editor.selection.focus, path)) {
26
29
  editor.insertFragment([{
27
30
  id: slugid.nice(),
28
31
  text: text
@@ -36,10 +39,28 @@ var withLink = function withLink(editor) {
36
39
  var text = data.getData('text/plain');
37
40
  if (isUrl(text) && !isImage(text)) {
38
41
  var link = genLinkNode(text, text);
39
- Transforms.insertNodes(newEditor, [link, {
40
- id: slugid.nice(),
41
- text: ' '
42
- }]);
42
+ Transforms.insertNodes(newEditor, link);
43
+ if (isSameDomain(text, context.getSetting('serviceUrl'))) {
44
+ context.getLinkFilesInfo([text]).then(function (res) {
45
+ if (isSdocFile(res, text)) {
46
+ var _Editor$nodes = Editor.nodes(editor, {
47
+ match: function match(n) {
48
+ return n.type === LINK;
49
+ },
50
+ universal: true
51
+ }),
52
+ _Editor$nodes2 = _slicedToArray(_Editor$nodes, 1),
53
+ nodeEntry = _Editor$nodes2[0];
54
+ var fileName = res.data.files_info[text].name;
55
+ var fileUuid = res.data.files_info[text].file_uuid;
56
+ Transforms.removeNodes(editor, {
57
+ at: nodeEntry[1]
58
+ });
59
+ insertSdocFileLink(editor, fileName, fileUuid);
60
+ return;
61
+ }
62
+ });
63
+ }
43
64
  return;
44
65
  }
45
66
  insertData(data);
@@ -51,7 +72,7 @@ var withLink = function withLink(editor) {
51
72
  node = _ref2[0],
52
73
  path = _ref2[1];
53
74
  var type = getNodeType(node);
54
- if (type !== 'link') {
75
+ if (type !== LINK) {
55
76
  // If the type is not link, perform default normalizeNode
56
77
  return normalizeNode([node, path]);
57
78
  }
@@ -11,20 +11,5 @@ var RenderElement = function RenderElement(props) {
11
11
  }, /*#__PURE__*/React.createElement(CustomElement, props));
12
12
  }
13
13
  return /*#__PURE__*/React.createElement(CustomElement, props);
14
-
15
- // const { element } = props;
16
- // const editor = useSlateStatic();
17
- // const comments = editor.element_comments_map?.[element.id] || [];
18
- // return (
19
- // <div className='seafile-block-container'>
20
- // <CustomElement {...props} />
21
- // {comments.length > 0 && (
22
- // <div className='comment-count'>
23
- // <span className='comment-count__btn'>{comments.length}</span>
24
- // </div>
25
- // )}
26
- // </div>
27
- // );
28
14
  };
29
-
30
15
  export default RenderElement;
@@ -6,4 +6,7 @@ export var isImage = function isImage(url) {
6
6
  var suffix = url.split('.')[1]; // http://xx/mm/*.png
7
7
  if (!suffix) return false;
8
8
  return IMAGE_TYPES.includes(suffix.toLowerCase());
9
+ };
10
+ export var isSameDomain = function isSameDomain(currentUrl, targetUrl) {
11
+ return String(currentUrl).split('/')[2] === String(targetUrl).split('/')[2];
9
12
  };
@@ -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
@@ -236,6 +236,18 @@ var Context = /*#__PURE__*/function () {
236
236
  var docUuid = this.getSetting('docUuid');
237
237
  return this.api.asyncCopyImages(docUuid, originDocUuid, imageList);
238
238
  }
239
+ }, {
240
+ key: "getLinkFilesInfo",
241
+ value: function getLinkFilesInfo(filesUrl) {
242
+ var docUuid = this.getSetting('docUuid');
243
+ return this.api.getLinkFilesInfo(docUuid, filesUrl);
244
+ }
245
+ }, {
246
+ key: "getCopyMoveProgressView",
247
+ value: function getCopyMoveProgressView(taskId) {
248
+ var docUuid = this.getSetting('docUuid');
249
+ return this.api.getCopyMoveProgressView(docUuid, taskId);
250
+ }
239
251
  }]);
240
252
  return Context;
241
253
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.173",
3
+ "version": "0.1.175",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",
@@ -10,9 +10,10 @@
10
10
  "@seafile/slate-history": "0.86.2",
11
11
  "@seafile/slate-hyperscript": "0.81.7",
12
12
  "@seafile/slate-react": "0.92.6",
13
- "ahooks": "3.7.7",
13
+ "axios": "1.4.0",
14
14
  "classnames": "2.3.2",
15
15
  "copy-to-clipboard": "^3.3.3",
16
+ "dayjs": "1.11.2",
16
17
  "deep-copy": "1.4.2",
17
18
  "is-hotkey": "0.2.0",
18
19
  "is-url": "^1.2.4",
@@ -26,8 +27,7 @@
26
27
  "socket.io-client": "4.6.1",
27
28
  "type-of": "2.0.1",
28
29
  "url-join": "4.0.1",
29
- "url-parse": "1.5.10",
30
- "uuid": "9.0.0"
30
+ "url-parse": "1.5.10"
31
31
  },
32
32
  "scripts": {
33
33
  "clean": "rm -rf dist && mkdir dist",
@@ -57,7 +57,6 @@
57
57
  "@types/jest": "29.0.0",
58
58
  "@typescript-eslint/eslint-plugin": "^2.2.0",
59
59
  "@typescript-eslint/parser": "^2.2.0",
60
- "axios": "1.4.0",
61
60
  "babel-eslint": "10.0.3",
62
61
  "babel-jest": "26.6.3",
63
62
  "babel-loader": "8.0.6",
@@ -70,7 +69,6 @@
70
69
  "core-js": "2.6.12",
71
70
  "css-loader": "^3.2.1",
72
71
  "css-minimizer-webpack-plugin": "5.0.1",
73
- "dayjs": "1.11.2",
74
72
  "dotenv": "6.2.0",
75
73
  "dotenv-expand": "5.1.0",
76
74
  "ejs": "3.1.8",
@@ -14,6 +14,10 @@
14
14
  />
15
15
  <missing-glyph />
16
16
 
17
+ <glyph glyph-name="sdoc-add-comment" unicode="&#58939;" d="M960 896c35.2 0 64-28.8 64-64v-704c0-35.2-28.8-64-64-64h-224l-224-192-224 192H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h896z m-32-96H96v-640h227.2l188.8-160 188.8 160H928V800zM288 528h448v-96H288zM464 704h96v-448h-96z" horiz-adv-x="1024" />
18
+
19
+ <glyph glyph-name="sdoc-comment-count" unicode="&#58966;" d="M1024 832v-704c0-35.2-28.8-64-64-64h-192l-256-192-224 192H64c-35.2 0-64 28.8-64 64V832C0 867.2 28.8 896 64 896h896c35.2 0 64-28.8 64-64z" horiz-adv-x="1024" />
20
+
17
21
  <glyph glyph-name="sdoc-link-file" unicode="&#58964;" d="M889.6-96H134.4c-22.4 0-38.4 16-38.4 38.4V825.6C96 848 112 864 134.4 864h480c22.4 0 54.4-6.4 80-35.2 44.8-51.2 188.8-208 195.2-214.4 3.2-3.2 38.4-38.4 38.4-73.6v-598.4c0-9.6-3.2-19.2-9.6-25.6-6.4-9.6-16-12.8-28.8-12.8zM192 0h640V544h-224V768H192v-768z" horiz-adv-x="1024" />
18
22
 
19
23
  <glyph glyph-name="sdoc-sm-close" unicode="&#58965;" d="M512 439.466667L230.4 721.066667l-25.6 25.6-55.466667-55.466667 25.6-25.6 281.6-281.6-281.6-281.6-25.6-25.6 55.466667-55.466667 25.6 25.6 281.6 281.6 281.6-281.6 25.6-25.6 55.466667 55.466667-25.6 25.6-281.6 281.6 281.6 281.6 25.6 25.6-55.466667 55.466667-25.6-25.6z" horiz-adv-x="1024" />
@@ -156,8 +160,6 @@
156
160
 
157
161
  <glyph glyph-name="sdoc-unstarred" unicode="&#58942;" d="M816 368c-60.8-60.8-86.4-150.4-73.6-236.8L768-32l-137.6 76.8c-35.2 19.2-76.8 32-118.4 32s-83.2-9.6-118.4-32L256-32l25.6 163.2c12.8 86.4-12.8 176-73.6 236.8L96 483.2l153.6 22.4c83.2 12.8 153.6 67.2 192 147.2L512 800l70.4-147.2c38.4-80 108.8-134.4 192-147.2l153.6-22.4-112-115.2z m179.2 44.8c54.4 54.4 25.6 153.6-51.2 163.2l-192 28.8c-28.8 3.2-57.6 25.6-70.4 54.4l-86.4 182.4C579.2 876.8 544 896 512 896s-67.2-19.2-83.2-54.4l-86.4-182.4c-12.8-28.8-38.4-48-70.4-51.2l-192-28.8C3.2 566.4-25.6 470.4 28.8 416l140.8-140.8c22.4-22.4 32-54.4 25.6-86.4l-32-201.6c-9.6-64 38.4-112 92.8-112 12.8 0 28.8 3.2 41.6 12.8l172.8 96c12.8 6.4 28.8 9.6 41.6 9.6 16 0 28.8-3.2 41.6-9.6l172.8-96c12.8-6.4 28.8-12.8 41.6-12.8 54.4 0 102.4 51.2 92.8 112l-32 201.6c-6.4 32 3.2 64 25.6 86.4l140.8 137.6z" horiz-adv-x="1024" />
158
162
 
159
- <glyph glyph-name="sdoc-comment" unicode="&#58939;" d="M886.4 800C928 800 960 768 960 726.4v-537.6c0-41.6-32-73.6-73.6-73.6h-192l-156.8-140.8c-12.8-12.8-35.2-12.8-48 0l-156.8 140.8h-192c-41.6 0-73.6 32-73.6 73.6V726.4C64 768 96 800 137.6 800h748.8z m0-73.6H137.6v-537.6h220.8l153.6-137.6 153.6 137.6h220.8V726.4zM665.6 480c19.2 0 38.4-16 38.4-38.4 0-19.2-16-35.2-38.4-38.4h-310.4c-19.2 0-38.4 16-38.4 38.4 0 19.2 16 35.2 38.4 38.4h310.4z m-115.2-192c0-19.2-16-38.4-38.4-38.4-19.2 0-35.2 16-38.4 38.4V598.4c0 19.2 16 38.4 38.4 38.4 19.2 0 35.2-16 38.4-38.4V288z" horiz-adv-x="1024" />
160
-
161
163
  <glyph glyph-name="sdoc-cancel" unicode="&#58929;" d="M512 441.6L214.4 742.4 185.6 768 128 710.4l25.6-28.8 300.8-297.6-300.8-297.6-25.6-28.8L185.6 0l28.8 25.6 297.6 300.8 297.6-300.8 28.8-25.6 57.6 57.6-25.6 28.8-300.8 297.6 300.8 297.6 25.6 28.8L838.4 768l-28.8-25.6-297.6-300.8z" horiz-adv-x="1024" />
162
164
 
163
165
  <glyph glyph-name="sdoc-fullscreen" unicode="&#58933;" d="M390.4 832c19.2 0 41.6-16 41.6-41.6s-16-41.6-41.6-41.6H147.2v-243.2c0-19.2-16-41.6-41.6-41.6S64 483.2 64 505.6V790.4C64 816 80 832 105.6 832h284.8z m0-812.8c19.2 0 41.6-16 41.6-41.6s-19.2-41.6-41.6-41.6H99.2c-6.4 0-16 3.2-22.4 9.6-9.6 6.4-12.8 16-12.8 25.6v288c0 19.2 16 41.6 41.6 41.6s41.6-16 41.6-41.6v-185.6l204.8 204.8c16 16 41.6 16 57.6 0s16-41.6 0-57.6l-204.8-204.8 185.6 3.2zM960 793.6c0-3.2 0-3.2 0 0v-284.8c0-19.2-16-41.6-41.6-41.6s-41.6 16-41.6 41.6V694.4L672 489.6c-16-16-41.6-16-57.6 0s-16 41.6 0 57.6l208 198.4h-185.6c-19.2 0-41.6 16-41.6 41.6S611.2 832 633.6 832H928c16-3.2 28.8-12.8 32-32v-6.4z m0-534.4v-281.6c0-19.2-16-41.6-41.6-41.6h-284.8c-19.2 0-41.6 16-41.6 41.6s16 41.6 41.6 41.6h243.2v240c0 25.6 19.2 41.6 41.6 41.6 22.4 0 41.6-16 41.6-41.6z" horiz-adv-x="1024" />
@@ -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=1695017062235'); /* IE9 */
4
- src: url('./sdoc-editor-font/iconfont.eot?t=1695017062235#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
- url('./sdoc-editor-font/iconfont.woff2?t=1695017062235') format('woff2'),
6
- url('./sdoc-editor-font/iconfont.woff?t=1695017062235') format('woff'),
7
- url('./sdoc-editor-font/iconfont.ttf?t=1695017062235') format('truetype'),
8
- url('./sdoc-editor-font/iconfont.svg?t=1695017062235#sdocfont') format('svg');
3
+ src: url('./sdoc-editor-font/iconfont.eot?t=1696755823394'); /* IE9 */
4
+ src: url('./sdoc-editor-font/iconfont.eot?t=1696755823394#iefix') format('embedded-opentype'), /* IE6-IE8 */
5
+ url('./sdoc-editor-font/iconfont.woff2?t=1696755823394') format('woff2'),
6
+ url('./sdoc-editor-font/iconfont.woff?t=1696755823394') format('woff'),
7
+ url('./sdoc-editor-font/iconfont.ttf?t=1696755823394') format('truetype'),
8
+ url('./sdoc-editor-font/iconfont.svg?t=1696755823394#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-add-comment:before {
20
+ content: "\e63b";
21
+ }
22
+
23
+ .sdoc-comment-count:before {
24
+ content: "\e656";
25
+ }
26
+
19
27
  .sdoc-link-file:before {
20
28
  content: "\e654";
21
29
  }
@@ -300,10 +308,6 @@
300
308
  content: "\e63e";
301
309
  }
302
310
 
303
- .sdoc-comment:before {
304
- content: "\e63b";
305
- }
306
-
307
311
  .sdoc-cancel:before {
308
312
  content: "\e631";
309
313
  }