@seafile/sdoc-editor 0.1.172 → 0.1.174
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/api/seafile-api.js +8 -0
- package/dist/basic-sdk/comment/comment/editor-comment.js +5 -2
- package/dist/basic-sdk/comment/comment/elements-comment-count/element-comment-count.js +40 -0
- package/dist/basic-sdk/comment/comment/elements-comment-count/index.css +29 -0
- package/dist/basic-sdk/comment/comment/elements-comment-count/index.js +24 -0
- package/dist/basic-sdk/comment/helper.js +18 -0
- package/dist/basic-sdk/decorates/index.js +1 -1
- package/dist/basic-sdk/editor/editable-article.js +1 -1
- package/dist/basic-sdk/extension/core/queries/index.js +24 -0
- package/dist/basic-sdk/extension/core/transforms/index.js +2 -1
- package/dist/basic-sdk/extension/core/transforms/update-parent-node.js +25 -0
- package/dist/basic-sdk/extension/plugins/link/dialog/add-link-dialog/index.js +5 -7
- package/dist/basic-sdk/extension/plugins/link/helpers.js +9 -1
- package/dist/basic-sdk/extension/plugins/link/plugin.js +30 -9
- package/dist/basic-sdk/extension/render/custom-element.js +148 -0
- package/dist/basic-sdk/extension/render/element-decorate/index.js +2 -0
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/index.js +29 -0
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-delete-modify-decorate.js +64 -0
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-delete-decorate.js +64 -0
- package/dist/basic-sdk/extension/render/element-decorate/rebase-decorate/rebase-modify-modify-decorate.js +97 -0
- package/dist/basic-sdk/extension/render/render-element.js +8 -380
- package/dist/basic-sdk/extension/utils/index.js +3 -0
- package/dist/basic-sdk/{highlight-decorate → highlight}/index.js +3 -1
- package/dist/basic-sdk/views/readonly-article.js +1 -1
- package/dist/components/doc-operations/revision-operations/more-revision-operations/index.css +1 -0
- package/dist/context.js +6 -0
- package/package.json +4 -6
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +4 -2
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
- package/public/media/sdoc-editor-font.css +14 -10
- /package/dist/basic-sdk/extension/core/transforms/{replace-node-children.js → replace-node.js} +0 -0
- /package/dist/basic-sdk/extension/render/{rebase-style.css → element-decorate/rebase-decorate/index.css} +0 -0
- /package/dist/basic-sdk/{highlight-decorate → highlight}/setNodeToDecorations.js +0 -0
package/dist/api/seafile-api.js
CHANGED
|
@@ -125,6 +125,14 @@ 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
|
+
}
|
|
128
136
|
}]);
|
|
129
137
|
return SeafileAPI;
|
|
130
138
|
}();
|
|
@@ -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(
|
|
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
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import { commentDecorate } from '../comment/comment-decorate';
|
|
3
|
-
import { highlightDecorate } from '../highlight
|
|
3
|
+
import { highlightDecorate } from '../highlight';
|
|
4
4
|
import useSelectionUpdate from '../hooks/use-selection-update';
|
|
5
5
|
var pluginDecorates = [highlightDecorate, commentDecorate];
|
|
6
6
|
export var usePipDecorate = function usePipDecorate(editor) {
|
|
@@ -5,7 +5,6 @@ import { getAboveBlockNode, getNextNode, getPrevNode, isSelectionAtBlockEnd, isS
|
|
|
5
5
|
import EventProxy from '../utils/event-handler';
|
|
6
6
|
import { useCursors } from '../cursor/use-cursors';
|
|
7
7
|
import { INTERNAL_EVENT } from '../constants';
|
|
8
|
-
import { SetNodeToDecorations } from '../highlight-decorate/setNodeToDecorations';
|
|
9
8
|
import CommentContextProvider from '../comment/comment-context-provider';
|
|
10
9
|
import CommentWrapper from '../comment';
|
|
11
10
|
import { usePipDecorate } from '../decorates';
|
|
@@ -13,6 +12,7 @@ import { getCursorPosition, getDomHeight, getDomMarginTop } from '../utils/dom-u
|
|
|
13
12
|
import EventBus from '../utils/event-bus';
|
|
14
13
|
import { ArticleContainer } from '../layout';
|
|
15
14
|
import { useScrollContext } from '../hooks/use-scroll-context';
|
|
15
|
+
import { SetNodeToDecorations } from '../highlight';
|
|
16
16
|
var EditableArticle = function EditableArticle(_ref) {
|
|
17
17
|
var isShowComment = _ref.isShowComment,
|
|
18
18
|
editor = _ref.editor,
|
|
@@ -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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { REBASE_MARK_KEY } from '../../../constants';
|
|
3
|
+
import { getNode } from '../queries';
|
|
4
|
+
import { replaceNode } from './replace-node';
|
|
5
|
+
export var updateRebaseParentNodeByPath = function updateRebaseParentNodeByPath(editor, path) {
|
|
6
|
+
var parentPath = path.slice(0, -1);
|
|
7
|
+
var parentNode = getNode(editor, parentPath);
|
|
8
|
+
if (parentNode.children.filter(function (item) {
|
|
9
|
+
return item[REBASE_MARK_KEY.REBASE_TYPE];
|
|
10
|
+
}).length !== 0) return;
|
|
11
|
+
var newParentElement = _objectSpread({}, parentNode);
|
|
12
|
+
newParentElement[REBASE_MARK_KEY.REBASE_TYPE] && delete newParentElement[REBASE_MARK_KEY.REBASE_TYPE];
|
|
13
|
+
newParentElement[REBASE_MARK_KEY.OLD_ELEMENT] && delete newParentElement[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
14
|
+
newParentElement[REBASE_MARK_KEY.ORIGIN] && delete newParentElement[REBASE_MARK_KEY.ORIGIN];
|
|
15
|
+
newParentElement['children'] = newParentElement['children'].map(function (item) {
|
|
16
|
+
item[REBASE_MARK_KEY.REBASE_TYPE] && delete item[REBASE_MARK_KEY.REBASE_TYPE];
|
|
17
|
+
item[REBASE_MARK_KEY.OLD_ELEMENT] && delete item[REBASE_MARK_KEY.OLD_ELEMENT];
|
|
18
|
+
item[REBASE_MARK_KEY.ORIGIN] && delete item[REBASE_MARK_KEY.ORIGIN];
|
|
19
|
+
return item;
|
|
20
|
+
});
|
|
21
|
+
replaceNode(editor, {
|
|
22
|
+
at: parentPath,
|
|
23
|
+
nodes: newParentElement
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -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(
|
|
93
|
-
|
|
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(
|
|
109
|
-
|
|
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
|
|
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 ===
|
|
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,
|
|
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,
|
|
40
|
-
|
|
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 !==
|
|
75
|
+
if (type !== LINK) {
|
|
55
76
|
// If the type is not link, perform default normalizeNode
|
|
56
77
|
return normalizeNode([node, path]);
|
|
57
78
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useSlateStatic } from '@seafile/slate-react';
|
|
4
|
+
import { BLOCKQUOTE, LINK, CHECK_LIST_ITEM, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, LIST_ITEM, LIST_LIC, ORDERED_LIST, PARAGRAPH, UNORDERED_LIST, CODE_BLOCK, CODE_LINE, IMAGE, ELEMENT_TYPE, SDOC_LINK, FILE_LINK, TITLE, SUBTITLE } from '../constants';
|
|
5
|
+
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin } from '../plugins';
|
|
6
|
+
import EventBus from '../../utils/event-bus';
|
|
7
|
+
import { INTERNAL_EVENT } from '../../constants';
|
|
8
|
+
var CustomRenderElement = function CustomRenderElement(props) {
|
|
9
|
+
var editor = useSlateStatic();
|
|
10
|
+
var element = props.element,
|
|
11
|
+
attributes = props.attributes;
|
|
12
|
+
var onMouseEnter = useCallback(function (event) {
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
var eventBus = EventBus.getInstance();
|
|
15
|
+
eventBus.dispatch(INTERNAL_EVENT.ON_MOUSE_ENTER_BLOCK, event);
|
|
16
|
+
}, []);
|
|
17
|
+
switch (element.type) {
|
|
18
|
+
case PARAGRAPH:
|
|
19
|
+
{
|
|
20
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
21
|
+
var _ParagraphPlugin$rend = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
22
|
+
renderParagraph = _ParagraphPlugin$rend[0];
|
|
23
|
+
return renderParagraph(props);
|
|
24
|
+
}
|
|
25
|
+
case TITLE:
|
|
26
|
+
{
|
|
27
|
+
var _HeaderPlugin$renderE = _slicedToArray(HeaderPlugin.renderElements, 1),
|
|
28
|
+
renderTitle = _HeaderPlugin$renderE[0];
|
|
29
|
+
return renderTitle(props, editor);
|
|
30
|
+
}
|
|
31
|
+
case SUBTITLE:
|
|
32
|
+
{
|
|
33
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
34
|
+
var _HeaderPlugin$renderE2 = _slicedToArray(HeaderPlugin.renderElements, 2),
|
|
35
|
+
renderSubtitle = _HeaderPlugin$renderE2[1];
|
|
36
|
+
return renderSubtitle(props, editor);
|
|
37
|
+
}
|
|
38
|
+
case HEADER1:
|
|
39
|
+
case HEADER2:
|
|
40
|
+
case HEADER3:
|
|
41
|
+
case HEADER4:
|
|
42
|
+
case HEADER5:
|
|
43
|
+
case HEADER6:
|
|
44
|
+
{
|
|
45
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
46
|
+
var _HeaderPlugin$renderE3 = _slicedToArray(HeaderPlugin.renderElements, 3),
|
|
47
|
+
renderHeader = _HeaderPlugin$renderE3[2];
|
|
48
|
+
return renderHeader(props, editor);
|
|
49
|
+
}
|
|
50
|
+
case LINK:
|
|
51
|
+
{
|
|
52
|
+
var _LinkPlugin$renderEle = _slicedToArray(LinkPlugin.renderElements, 1),
|
|
53
|
+
renderLink = _LinkPlugin$renderEle[0];
|
|
54
|
+
return renderLink(props, editor);
|
|
55
|
+
}
|
|
56
|
+
case BLOCKQUOTE:
|
|
57
|
+
{
|
|
58
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
59
|
+
var _BlockquotePlugin$ren = _slicedToArray(BlockquotePlugin.renderElements, 1),
|
|
60
|
+
renderBlockquote = _BlockquotePlugin$ren[0];
|
|
61
|
+
return renderBlockquote(props, editor);
|
|
62
|
+
}
|
|
63
|
+
case ORDERED_LIST:
|
|
64
|
+
case UNORDERED_LIST:
|
|
65
|
+
{
|
|
66
|
+
var _ListPlugin$renderEle = _slicedToArray(ListPlugin.renderElements, 1),
|
|
67
|
+
renderList = _ListPlugin$renderEle[0];
|
|
68
|
+
return renderList(props, editor);
|
|
69
|
+
}
|
|
70
|
+
case LIST_ITEM:
|
|
71
|
+
{
|
|
72
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
73
|
+
var _ListPlugin$renderEle2 = _slicedToArray(ListPlugin.renderElements, 2),
|
|
74
|
+
renderListItem = _ListPlugin$renderEle2[1];
|
|
75
|
+
return renderListItem(props, editor);
|
|
76
|
+
}
|
|
77
|
+
case LIST_LIC:
|
|
78
|
+
{
|
|
79
|
+
var _ListPlugin$renderEle3 = _slicedToArray(ListPlugin.renderElements, 3),
|
|
80
|
+
renderListLic = _ListPlugin$renderEle3[2];
|
|
81
|
+
return renderListLic(props, editor);
|
|
82
|
+
}
|
|
83
|
+
case CHECK_LIST_ITEM:
|
|
84
|
+
{
|
|
85
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
86
|
+
var _CheckListPlugin$rend = _slicedToArray(CheckListPlugin.renderElements, 1),
|
|
87
|
+
renderCheckListItem = _CheckListPlugin$rend[0];
|
|
88
|
+
return renderCheckListItem(props, editor);
|
|
89
|
+
}
|
|
90
|
+
case CODE_BLOCK:
|
|
91
|
+
{
|
|
92
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
93
|
+
var _CodeBlockPlugin$rend = _slicedToArray(CodeBlockPlugin.renderElements, 1),
|
|
94
|
+
renderCodeBlock = _CodeBlockPlugin$rend[0];
|
|
95
|
+
return renderCodeBlock(props, editor);
|
|
96
|
+
}
|
|
97
|
+
case CODE_LINE:
|
|
98
|
+
{
|
|
99
|
+
var _CodeBlockPlugin$rend2 = _slicedToArray(CodeBlockPlugin.renderElements, 2),
|
|
100
|
+
renderCodeLine = _CodeBlockPlugin$rend2[1];
|
|
101
|
+
return renderCodeLine(props, editor);
|
|
102
|
+
}
|
|
103
|
+
case IMAGE:
|
|
104
|
+
{
|
|
105
|
+
var _ImagePlugin$renderEl = _slicedToArray(ImagePlugin.renderElements, 1),
|
|
106
|
+
renderImage = _ImagePlugin$renderEl[0];
|
|
107
|
+
return renderImage(props, editor);
|
|
108
|
+
}
|
|
109
|
+
case ELEMENT_TYPE.TABLE:
|
|
110
|
+
{
|
|
111
|
+
attributes['onMouseEnter'] = onMouseEnter;
|
|
112
|
+
var _TablePlugin$renderEl = _slicedToArray(TablePlugin.renderElements, 1),
|
|
113
|
+
renderTable = _TablePlugin$renderEl[0];
|
|
114
|
+
return renderTable(props, editor);
|
|
115
|
+
}
|
|
116
|
+
case ELEMENT_TYPE.TABLE_ROW:
|
|
117
|
+
{
|
|
118
|
+
var _TablePlugin$renderEl2 = _slicedToArray(TablePlugin.renderElements, 2),
|
|
119
|
+
renderTableRow = _TablePlugin$renderEl2[1];
|
|
120
|
+
return renderTableRow(props, editor);
|
|
121
|
+
}
|
|
122
|
+
case ELEMENT_TYPE.TABLE_CELL:
|
|
123
|
+
{
|
|
124
|
+
var _TablePlugin$renderEl3 = _slicedToArray(TablePlugin.renderElements, 3),
|
|
125
|
+
renderTableCell = _TablePlugin$renderEl3[2];
|
|
126
|
+
return renderTableCell(props, editor);
|
|
127
|
+
}
|
|
128
|
+
case SDOC_LINK:
|
|
129
|
+
{
|
|
130
|
+
var _SdocLinkPlugin$rende = _slicedToArray(SdocLinkPlugin.renderElements, 1),
|
|
131
|
+
renderSdocLink = _SdocLinkPlugin$rende[0];
|
|
132
|
+
return renderSdocLink(props, editor);
|
|
133
|
+
}
|
|
134
|
+
case FILE_LINK:
|
|
135
|
+
{
|
|
136
|
+
var _FileLinkPlugin$rende = _slicedToArray(FileLinkPlugin.renderElements, 1),
|
|
137
|
+
renderFileLink = _FileLinkPlugin$rende[0];
|
|
138
|
+
return renderFileLink(props, editor);
|
|
139
|
+
}
|
|
140
|
+
default:
|
|
141
|
+
{
|
|
142
|
+
var _ParagraphPlugin$rend2 = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
143
|
+
_renderParagraph = _ParagraphPlugin$rend2[0];
|
|
144
|
+
return _renderParagraph(props);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
export default CustomRenderElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import RebaseModifyDeleteDecorate from './rebase-modify-delete-decorate';
|
|
3
|
+
import RebaseModifyModifyDecorate from './rebase-modify-modify-decorate';
|
|
4
|
+
import RebaseDeleteModifyDecorate from './rebase-delete-modify-decorate';
|
|
5
|
+
import { REBASE_MARK_KEY, REBASE_TYPE } from '../../../../constants';
|
|
6
|
+
import './index.css';
|
|
7
|
+
var RebaseDecorate = function RebaseDecorate(_ref) {
|
|
8
|
+
var element = _ref.element,
|
|
9
|
+
children = _ref.children;
|
|
10
|
+
var rebaseType = element[REBASE_MARK_KEY.REBASE_TYPE];
|
|
11
|
+
if (!rebaseType) return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
12
|
+
if (rebaseType === REBASE_TYPE.MODIFY_DELETE) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(RebaseModifyDeleteDecorate, {
|
|
14
|
+
element: element
|
|
15
|
+
}, children);
|
|
16
|
+
}
|
|
17
|
+
if (rebaseType === REBASE_TYPE.DELETE_MODIFY) {
|
|
18
|
+
return /*#__PURE__*/React.createElement(RebaseDeleteModifyDecorate, {
|
|
19
|
+
element: element
|
|
20
|
+
}, children);
|
|
21
|
+
}
|
|
22
|
+
if (rebaseType === REBASE_TYPE.MODIFY_MODIFY) {
|
|
23
|
+
return /*#__PURE__*/React.createElement(RebaseModifyModifyDecorate, {
|
|
24
|
+
element: element
|
|
25
|
+
}, children);
|
|
26
|
+
}
|
|
27
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
28
|
+
};
|
|
29
|
+
export default RebaseDecorate;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Transforms } from '@seafile/slate';
|
|
4
|
+
import { useSlateStatic } from '@seafile/slate-react';
|
|
5
|
+
import { ELEMENT_TYPE } from '../../../constants';
|
|
6
|
+
import { REBASE_MARKS } from '../../../../constants';
|
|
7
|
+
import { findPath, deleteNodeMark, updateRebaseParentNodeByPath } from '../../../core';
|
|
8
|
+
var RebaseDeleteModifyDecorate = function RebaseDeleteModifyDecorate(_ref) {
|
|
9
|
+
var element = _ref.element,
|
|
10
|
+
children = _ref.children;
|
|
11
|
+
var _useTranslation = useTranslation(),
|
|
12
|
+
t = _useTranslation.t;
|
|
13
|
+
var editor = useSlateStatic();
|
|
14
|
+
var deleteElement = useCallback(function () {
|
|
15
|
+
var path = findPath(editor, element);
|
|
16
|
+
Transforms.removeNodes(editor, {
|
|
17
|
+
at: path
|
|
18
|
+
});
|
|
19
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
20
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [editor, element]);
|
|
25
|
+
var deleteMark = useCallback(function () {
|
|
26
|
+
var path = findPath(editor, element);
|
|
27
|
+
deleteNodeMark(editor, path, element, REBASE_MARKS);
|
|
28
|
+
if (element.type === ELEMENT_TYPE.LIST_ITEM) {
|
|
29
|
+
updateRebaseParentNodeByPath(editor, path);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [editor, element]);
|
|
34
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "w-100 d-flex sdoc-rebase-btn-group",
|
|
36
|
+
contentEditable: false
|
|
37
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
className: "sdoc-rebase-btn",
|
|
39
|
+
onClick: deleteElement
|
|
40
|
+
}, t('Keep_other_modification')), /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
className: "mr-2 ml-2"
|
|
42
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: "sdoc-rebase-btn",
|
|
44
|
+
onClick: deleteMark
|
|
45
|
+
}, t('Keep_my_modification')), /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "mr-2 ml-2"
|
|
47
|
+
}, '|'), /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "sdoc-rebase-btn",
|
|
49
|
+
onClick: deleteMark
|
|
50
|
+
}, t('Keep_both_modification'))), /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "w-100 sdoc-rebase-current-changes-start",
|
|
52
|
+
contentEditable: false
|
|
53
|
+
}, '<<<<<<<'), /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "w-100",
|
|
55
|
+
contentEditable: false
|
|
56
|
+
}, '======='), /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "w-100 sdoc-rebase-incoming-changes",
|
|
58
|
+
contentEditable: false
|
|
59
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: "w-100 sdoc-rebase-incoming-changes-end",
|
|
61
|
+
contentEditable: false
|
|
62
|
+
}, '>>>>>>>'));
|
|
63
|
+
};
|
|
64
|
+
export default RebaseDeleteModifyDecorate;
|