@seafile/sdoc-editor 0.1.150 → 0.1.151
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 -2
- package/dist/basic-sdk/assets/css/code-block.css +3 -0
- package/dist/basic-sdk/extension/commons/insert-element-dialog/index.js +30 -3
- package/dist/basic-sdk/extension/commons/select-file-dialog/helpers.js +17 -0
- package/dist/basic-sdk/extension/{plugins/sdoc-link/dialog/select-sdoc-file-dialog → commons/select-file-dialog}/index.js +39 -4
- package/dist/basic-sdk/extension/commons/select-file-dialog/local-files/index.js +174 -0
- package/dist/basic-sdk/extension/constants/element-type.js +1 -0
- package/dist/basic-sdk/extension/constants/index.js +6 -2
- package/dist/basic-sdk/extension/plugins/file-link/constants/index.js +18 -0
- package/dist/basic-sdk/extension/plugins/file-link/helpers.js +113 -0
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.css +89 -0
- package/dist/basic-sdk/extension/plugins/file-link/hover-menu/index.js +113 -0
- package/dist/basic-sdk/extension/plugins/file-link/index.js +11 -0
- package/dist/basic-sdk/extension/plugins/file-link/menu/index.js +28 -0
- package/dist/basic-sdk/extension/plugins/file-link/plugin.js +40 -0
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.css +41 -0
- package/dist/basic-sdk/extension/plugins/file-link/render-elem.js +141 -0
- package/dist/basic-sdk/extension/plugins/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/sdoc-link/helpers.js +0 -16
- package/dist/basic-sdk/extension/plugins/sdoc-link/menu/index.js +3 -2
- package/dist/basic-sdk/extension/render/render-element.js +8 -2
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +2 -1
- package/dist/context.js +8 -2
- package/package.json +1 -1
- package/public/locales/en/sdoc-editor.json +3 -1
- package/public/locales/zh_CN/sdoc-editor.json +1 -0
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -0
- 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 +10 -6
- package/dist/basic-sdk/extension/plugins/sdoc-link/dialog/select-sdoc-file-dialog/local-files/index.js +0 -143
- /package/dist/basic-sdk/extension/{plugins/sdoc-link/dialog/select-sdoc-file-dialog → commons/select-file-dialog}/index.css +0 -0
- /package/dist/basic-sdk/extension/{plugins/sdoc-link/dialog/select-sdoc-file-dialog → commons/select-file-dialog}/local-files/index.css +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
|
+
import { Transforms } from '@seafile/slate';
|
|
4
|
+
import { ReactEditor, useReadOnly } from '@seafile/slate-react';
|
|
5
|
+
import { withTranslation } from 'react-i18next';
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
import { FILE_LINK_TYPE_CONFIG, FILE_LINK_TYPE, FILE_LINK_TYPES } from '../constants';
|
|
8
|
+
import { ElementPopover } from '../../../commons';
|
|
9
|
+
import toaster from '../../../../../components/toast';
|
|
10
|
+
import { getUrl, onCopyFileLinkNode } from '../helpers';
|
|
11
|
+
import './index.css';
|
|
12
|
+
var FileLinkHoverMenu = function FileLinkHoverMenu(_ref) {
|
|
13
|
+
var editor = _ref.editor,
|
|
14
|
+
menuPosition = _ref.menuPosition,
|
|
15
|
+
element = _ref.element,
|
|
16
|
+
onUnwrapFileLinkNode = _ref.onUnwrapFileLinkNode,
|
|
17
|
+
onHideInsertHoverMenu = _ref.onHideInsertHoverMenu,
|
|
18
|
+
t = _ref.t;
|
|
19
|
+
var readOnly = useReadOnly();
|
|
20
|
+
var _useState = useState(false),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
isShowDisplayStylePopover = _useState2[0],
|
|
23
|
+
setIsShowDisplayStylePopover = _useState2[1];
|
|
24
|
+
var onCopy = useCallback(function (e) {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
onCopyFileLinkNode(editor, element);
|
|
27
|
+
toaster.success(t('Copied'), {
|
|
28
|
+
hasCloseButton: false,
|
|
29
|
+
duration: 2
|
|
30
|
+
});
|
|
31
|
+
onHideInsertHoverMenu();
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, []);
|
|
34
|
+
var onShowProver = useCallback(function (e) {
|
|
35
|
+
setIsShowDisplayStylePopover(true);
|
|
36
|
+
}, []);
|
|
37
|
+
var onSelect = useCallback(function (event, value) {
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
var path = ReactEditor.findPath(editor, element);
|
|
40
|
+
if (path) {
|
|
41
|
+
Transforms.setNodes(editor, {
|
|
42
|
+
display_type: value
|
|
43
|
+
}, {
|
|
44
|
+
at: path
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
onHideInsertHoverMenu();
|
|
48
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
+
}, []);
|
|
50
|
+
var selectedType = element.display_type || FILE_LINK_TYPE.TEXT_LINK;
|
|
51
|
+
var id = "file-link-display-type-".concat(element.id);
|
|
52
|
+
return /*#__PURE__*/React.createElement(ElementPopover, null, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "sdoc-file-link-hover-menu-container",
|
|
54
|
+
style: menuPosition
|
|
55
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: "hover-menu-container"
|
|
57
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
58
|
+
className: "op-group-item"
|
|
59
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
60
|
+
role: "button",
|
|
61
|
+
className: classnames('op-item', {
|
|
62
|
+
'ml-0': readOnly
|
|
63
|
+
})
|
|
64
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
65
|
+
href: getUrl(element.doc_uuid),
|
|
66
|
+
target: "_blank",
|
|
67
|
+
rel: "noopener noreferrer",
|
|
68
|
+
className: "link-op-menu-link"
|
|
69
|
+
}, t('Open_link')))), !readOnly && /*#__PURE__*/React.createElement("span", {
|
|
70
|
+
className: "op-group-item"
|
|
71
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
72
|
+
role: "button",
|
|
73
|
+
className: "op-item",
|
|
74
|
+
onClick: onCopy
|
|
75
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
76
|
+
className: "sdocfont sdoc-copy icon-font"
|
|
77
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
78
|
+
role: "button",
|
|
79
|
+
className: classnames('op-item', {
|
|
80
|
+
'link-style-icon-active': isShowDisplayStylePopover
|
|
81
|
+
}),
|
|
82
|
+
onClick: onShowProver,
|
|
83
|
+
id: id
|
|
84
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
85
|
+
className: classnames('icon-font mr-1', FILE_LINK_TYPE_CONFIG[selectedType].icon)
|
|
86
|
+
}), /*#__PURE__*/React.createElement("i", {
|
|
87
|
+
className: "sdocfont sdoc-drop-down icon-font"
|
|
88
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
89
|
+
role: "button",
|
|
90
|
+
className: "op-item",
|
|
91
|
+
onClick: onUnwrapFileLinkNode
|
|
92
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
93
|
+
className: "sdocfont sdoc-unlink icon-font"
|
|
94
|
+
})))), isShowDisplayStylePopover && /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
className: "sdoc-file-display-style-popover sdoc-dropdown-menu"
|
|
96
|
+
}, FILE_LINK_TYPES.map(function (fileLinkType) {
|
|
97
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
key: fileLinkType,
|
|
99
|
+
"date-type": fileLinkType,
|
|
100
|
+
className: "sdoc-dropdown-menu-item sdoc-dropdown-item-with-left-icon pr-2",
|
|
101
|
+
onClick: function onClick(event) {
|
|
102
|
+
return onSelect(event, fileLinkType);
|
|
103
|
+
}
|
|
104
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
105
|
+
className: "sdoc-dropdown-item-content"
|
|
106
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
107
|
+
className: classnames('sdoc-dropdown-item-content-icon', FILE_LINK_TYPE_CONFIG[fileLinkType].icon)
|
|
108
|
+
}), /*#__PURE__*/React.createElement("span", null, t(FILE_LINK_TYPE_CONFIG[fileLinkType].text))), selectedType === fileLinkType && /*#__PURE__*/React.createElement("i", {
|
|
109
|
+
className: "sdocfont sdoc-check-mark sdoc-dropdown-item-right-icon"
|
|
110
|
+
}));
|
|
111
|
+
}))));
|
|
112
|
+
};
|
|
113
|
+
export default withTranslation('sdoc-editor')(FileLinkHoverMenu);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FILE_LINK } from '../../constants';
|
|
2
|
+
import FileLinkMenu from './menu';
|
|
3
|
+
import withFileLink from './plugin';
|
|
4
|
+
import renderFileLink from './render-elem';
|
|
5
|
+
var FileLinkPlugin = {
|
|
6
|
+
type: FILE_LINK,
|
|
7
|
+
editorMenus: [FileLinkMenu],
|
|
8
|
+
editorPlugin: withFileLink,
|
|
9
|
+
renderElements: [renderFileLink]
|
|
10
|
+
};
|
|
11
|
+
export default FileLinkPlugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { FILE_LINK, MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../../../constants';
|
|
3
|
+
import { isMenuDisabled, insertFileLink } from '../helpers';
|
|
4
|
+
import DropdownMenuItem from '../../../commons/dropdown-menu-item';
|
|
5
|
+
import { INTERNAL_EVENT } from '../../../../constants';
|
|
6
|
+
var FileLinkMenu = function FileLinkMenu(_ref) {
|
|
7
|
+
var editor = _ref.editor,
|
|
8
|
+
readonly = _ref.readonly,
|
|
9
|
+
toggle = _ref.toggle,
|
|
10
|
+
eventBus = _ref.eventBus;
|
|
11
|
+
var disabled = isMenuDisabled(editor, readonly);
|
|
12
|
+
var menuConfig = MENUS_CONFIG_MAP[FILE_LINK];
|
|
13
|
+
var openSelectFileDialog = useCallback(function () {
|
|
14
|
+
eventBus.dispatch(INTERNAL_EVENT.INSERT_ELEMENT, {
|
|
15
|
+
type: ELEMENT_TYPE.FILE_LINK,
|
|
16
|
+
insertFileLinkCallback: insertFileLink
|
|
17
|
+
});
|
|
18
|
+
toggle && toggle();
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
}, [toggle, eventBus]);
|
|
22
|
+
return /*#__PURE__*/React.createElement(DropdownMenuItem, {
|
|
23
|
+
disabled: disabled,
|
|
24
|
+
menuConfig: menuConfig,
|
|
25
|
+
onClick: openSelectFileDialog
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export default FileLinkMenu;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Transforms, Node, Editor } from '@seafile/slate';
|
|
2
|
+
import { FILE_LINK } from '../../constants';
|
|
3
|
+
var withFileLink = function withFileLink(editor) {
|
|
4
|
+
var isInline = editor.isInline,
|
|
5
|
+
deleteBackward = editor.deleteBackward;
|
|
6
|
+
var newEditor = editor;
|
|
7
|
+
|
|
8
|
+
// Rewrite isInline
|
|
9
|
+
newEditor.isInline = function (elem) {
|
|
10
|
+
var type = elem.type;
|
|
11
|
+
if (type === FILE_LINK) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return isInline(elem);
|
|
15
|
+
};
|
|
16
|
+
newEditor.deleteBackward = function (unit) {
|
|
17
|
+
var selection = newEditor.selection;
|
|
18
|
+
if (selection === null) {
|
|
19
|
+
return deleteBackward(unit);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Delete file link node
|
|
23
|
+
var nodeEntry = Editor.node(newEditor, newEditor.selection);
|
|
24
|
+
if (nodeEntry && Node.string(nodeEntry[0]).length === 0) {
|
|
25
|
+
var beforePath = nodeEntry[1];
|
|
26
|
+
beforePath.splice(-1, 1, Math.max(nodeEntry[1].at(-1) - 1, 0));
|
|
27
|
+
var beforeNodeEntry = Editor.node(newEditor, beforePath);
|
|
28
|
+
if (beforeNodeEntry && beforeNodeEntry[0].type === FILE_LINK) {
|
|
29
|
+
Transforms.delete(newEditor, {
|
|
30
|
+
at: beforeNodeEntry[1]
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
return deleteBackward(unit);
|
|
35
|
+
}
|
|
36
|
+
return deleteBackward(unit);
|
|
37
|
+
};
|
|
38
|
+
return newEditor;
|
|
39
|
+
};
|
|
40
|
+
export default withFileLink;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.sdoc-file-link-render:hover {
|
|
2
|
+
background-color: #e5e5e5
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.sdoc-file-card-link {
|
|
6
|
+
position: relative;
|
|
7
|
+
background-color: #f3f3f3;
|
|
8
|
+
border: 1px solid transparent;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
display: inline-block;
|
|
12
|
+
height: 50px;
|
|
13
|
+
width: 420px;
|
|
14
|
+
margin-bottom: -3px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.sdoc-file-link-render .sdoc-file-link-icon {
|
|
18
|
+
padding-right: 5px;
|
|
19
|
+
color: #ff9800;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sdoc-file-card-link .sdoc-file-link-icon :first-child {
|
|
23
|
+
font-size: 24px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sdoc-file-card-link .sdoc-file-link-icon {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 6px;
|
|
29
|
+
left: 12px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sdoc-file-card-link .sdoc-file-text-link {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 16px;
|
|
35
|
+
left: 42px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sdoc-file-card-link .sdoc-file-text-link a {
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
color: #333;
|
|
41
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useCallback, useEffect, useState, useRef } from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { Range } from '@seafile/slate';
|
|
6
|
+
import { useReadOnly } from '@seafile/slate-react';
|
|
7
|
+
import { useScrollContext } from '../../../hooks/use-scroll-context';
|
|
8
|
+
import { unwrapLinkNode, getUrl } from './helpers';
|
|
9
|
+
import HoverMenu from './hover-menu';
|
|
10
|
+
import { DELETED_STYLE, ADDED_STYLE } from '../../constants';
|
|
11
|
+
import { FILE_LINK_TYPE } from './constants';
|
|
12
|
+
import './render-elem.css';
|
|
13
|
+
var FileLink = function FileLink(_ref) {
|
|
14
|
+
var editor = _ref.editor,
|
|
15
|
+
element = _ref.element,
|
|
16
|
+
children = _ref.children,
|
|
17
|
+
attributes = _ref.attributes;
|
|
18
|
+
var fileRef = useRef(null);
|
|
19
|
+
var scrollRef = useScrollContext();
|
|
20
|
+
var _useState = useState(false),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
isShowInsertHoverMenu = _useState2[0],
|
|
23
|
+
setIsShowInsertHoverMenu = _useState2[1];
|
|
24
|
+
var _useState3 = useState({}),
|
|
25
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
26
|
+
menuPosition = _useState4[0],
|
|
27
|
+
setMenuPosition = _useState4[1];
|
|
28
|
+
var readOnly = useReadOnly();
|
|
29
|
+
var registerEventHandle = useCallback(function () {
|
|
30
|
+
document.addEventListener('click', onHideInsertHoverMenu);
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, []);
|
|
33
|
+
var unregisterEventHandle = useCallback(function () {
|
|
34
|
+
document.removeEventListener('click', onHideInsertHoverMenu);
|
|
35
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
}, []);
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
return function () {
|
|
39
|
+
unregisterEventHandle();
|
|
40
|
+
};
|
|
41
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
+
}, []);
|
|
43
|
+
var setPosition = useCallback(function (elem) {
|
|
44
|
+
if (elem) {
|
|
45
|
+
var _elem$getBoundingClie = elem.getBoundingClientRect(),
|
|
46
|
+
top = _elem$getBoundingClie.top,
|
|
47
|
+
left = _elem$getBoundingClie.left;
|
|
48
|
+
var menuTop = top - 42; // top = top distance - menu height
|
|
49
|
+
var menuLeft = left - 18; // left = left distance - (menu width / 2)
|
|
50
|
+
var newMenuPosition = {
|
|
51
|
+
top: menuTop,
|
|
52
|
+
left: menuLeft
|
|
53
|
+
};
|
|
54
|
+
setMenuPosition(newMenuPosition);
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
}, []);
|
|
58
|
+
var onScroll = useCallback(function (e) {
|
|
59
|
+
setPosition(fileRef.current);
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
}, []);
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
var observerRefValue = null;
|
|
64
|
+
if (isShowInsertHoverMenu) {
|
|
65
|
+
scrollRef.current && scrollRef.current.addEventListener('scroll', onScroll);
|
|
66
|
+
observerRefValue = scrollRef.current;
|
|
67
|
+
} else {
|
|
68
|
+
scrollRef.current && scrollRef.current.removeEventListener('scroll', onScroll);
|
|
69
|
+
}
|
|
70
|
+
return function () {
|
|
71
|
+
if (observerRefValue) {
|
|
72
|
+
observerRefValue.removeEventListener('scroll', onScroll);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
}, [isShowInsertHoverMenu]);
|
|
77
|
+
var onClickFile = useCallback(function (e) {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
setPosition(e.currentTarget);
|
|
80
|
+
setIsShowInsertHoverMenu(true);
|
|
81
|
+
setTimeout(function () {
|
|
82
|
+
registerEventHandle();
|
|
83
|
+
}, 0);
|
|
84
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
|
+
}, []);
|
|
86
|
+
var onHideInsertHoverMenu = useCallback(function (e) {
|
|
87
|
+
setIsShowInsertHoverMenu(false);
|
|
88
|
+
unregisterEventHandle();
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
}, []);
|
|
91
|
+
var onUnwrapFileLinkNode = useCallback(function () {
|
|
92
|
+
unwrapLinkNode(editor, element);
|
|
93
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
}, []);
|
|
95
|
+
var style = {};
|
|
96
|
+
if (element.ADD) {
|
|
97
|
+
style = _objectSpread({}, ADDED_STYLE);
|
|
98
|
+
} else if (element.DELETE) {
|
|
99
|
+
style = _objectSpread({}, DELETED_STYLE);
|
|
100
|
+
}
|
|
101
|
+
if (style.computed_bg_color) {
|
|
102
|
+
style['backgroundColor'] = style.computed_bg_color;
|
|
103
|
+
}
|
|
104
|
+
return /*#__PURE__*/React.createElement("span", Object.assign({}, attributes, {
|
|
105
|
+
"data-id": element.id,
|
|
106
|
+
contentEditable: false,
|
|
107
|
+
className: classnames('sdoc-file-link-render', {
|
|
108
|
+
'sdoc-file-card-link': element.display_type === FILE_LINK_TYPE.CARD_LINK
|
|
109
|
+
}),
|
|
110
|
+
onClick: onClickFile,
|
|
111
|
+
style: element.display_type === FILE_LINK_TYPE.CARD_LINK ? style : {}
|
|
112
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
113
|
+
ref: fileRef
|
|
114
|
+
}, [FILE_LINK_TYPE.ICON_LINK, FILE_LINK_TYPE.CARD_LINK].includes(element.display_type) && /*#__PURE__*/React.createElement("span", {
|
|
115
|
+
className: "sdoc-file-link-icon",
|
|
116
|
+
style: style
|
|
117
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
118
|
+
className: "sdocfont sdoc-document"
|
|
119
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
120
|
+
className: "sdoc-file-text-link",
|
|
121
|
+
style: style
|
|
122
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
123
|
+
href: getUrl(element.doc_uuid),
|
|
124
|
+
onClick: function onClick(e) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
},
|
|
127
|
+
title: element.title
|
|
128
|
+
}, children))), isShowInsertHoverMenu && (!readOnly && Range.isCollapsed(editor.selection) || readOnly) && /*#__PURE__*/React.createElement(HoverMenu, {
|
|
129
|
+
editor: editor,
|
|
130
|
+
menuPosition: menuPosition,
|
|
131
|
+
element: element,
|
|
132
|
+
onUnwrapFileLinkNode: onUnwrapFileLinkNode,
|
|
133
|
+
onHideInsertHoverMenu: onHideInsertHoverMenu
|
|
134
|
+
}));
|
|
135
|
+
};
|
|
136
|
+
var renderFileLink = function renderFileLink(props, editor) {
|
|
137
|
+
return /*#__PURE__*/React.createElement(FileLink, Object.assign({}, props, {
|
|
138
|
+
editor: editor
|
|
139
|
+
}));
|
|
140
|
+
};
|
|
141
|
+
export default renderFileLink;
|
|
@@ -12,7 +12,8 @@ import HtmlPlugin from './html';
|
|
|
12
12
|
import TextAlignPlugin from './text-align';
|
|
13
13
|
import FontPlugin from './font';
|
|
14
14
|
import SdocLinkPlugin from './sdoc-link';
|
|
15
|
+
import FileLinkPlugin from './file-link';
|
|
15
16
|
import ParagraphPlugin from './paragraph';
|
|
16
|
-
var Plugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin];
|
|
17
|
+
var Plugins = [MarkDownPlugin, HtmlPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, FileLinkPlugin];
|
|
17
18
|
export default Plugins;
|
|
18
|
-
export { MarkDownPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, HtmlPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin };
|
|
19
|
+
export { MarkDownPlugin, HeaderPlugin, LinkPlugin, BlockquotePlugin, ListPlugin, CheckListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, TextPlugin, HtmlPlugin, TextAlignPlugin, FontPlugin, SdocLinkPlugin, ParagraphPlugin, FileLinkPlugin };
|
|
@@ -94,22 +94,6 @@ export var unwrapLinkNode = function unwrapLinkNode(editor, element) {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
export var getParentPathNameArr = function getParentPathNameArr(fileListData, indexId, indexArray) {
|
|
98
|
-
var arr = Array.from(indexArray);
|
|
99
|
-
for (var i = 0, len = fileListData.length; i < len; i++) {
|
|
100
|
-
arr.push(fileListData[i].name);
|
|
101
|
-
if (fileListData[i].indexId === indexId) {
|
|
102
|
-
return arr;
|
|
103
|
-
}
|
|
104
|
-
var children = fileListData[i].children;
|
|
105
|
-
if (children && children.length) {
|
|
106
|
-
var result = getParentPathNameArr(children, indexId, arr);
|
|
107
|
-
if (result) return result;
|
|
108
|
-
}
|
|
109
|
-
arr.pop();
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
};
|
|
113
97
|
export var getNewFileListData = function getNewFileListData(fileListData, indexId, children) {
|
|
114
98
|
fileListData.forEach(function (item) {
|
|
115
99
|
if (item.indexId === indexId) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { SDOC_LINK, MENUS_CONFIG_MAP, ELEMENT_TYPE } from '../../../constants';
|
|
3
|
-
import { isMenuDisabled } from '../helpers';
|
|
3
|
+
import { isMenuDisabled, insertSdocFileLink } from '../helpers';
|
|
4
4
|
import DropdownMenuItem from '../../../commons/dropdown-menu-item';
|
|
5
5
|
import { INTERNAL_EVENT } from '../../../../constants';
|
|
6
6
|
var SdocLinkMenu = function SdocLinkMenu(_ref) {
|
|
@@ -12,7 +12,8 @@ var SdocLinkMenu = function SdocLinkMenu(_ref) {
|
|
|
12
12
|
var menuConfig = MENUS_CONFIG_MAP[SDOC_LINK];
|
|
13
13
|
var openSelectSdocFileDialog = useCallback(function () {
|
|
14
14
|
eventBus.dispatch(INTERNAL_EVENT.INSERT_ELEMENT, {
|
|
15
|
-
type: ELEMENT_TYPE.SDOC_LINK
|
|
15
|
+
type: ELEMENT_TYPE.SDOC_LINK,
|
|
16
|
+
insertSdocFileLinkCallback: insertSdocFileLink
|
|
16
17
|
});
|
|
17
18
|
toggle && toggle();
|
|
18
19
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
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, TITLE, SUBTITLE } from '../constants';
|
|
5
|
-
import { BlockquotePlugin, LinkPlugin, CheckListPlugin, HeaderPlugin, ListPlugin, CodeBlockPlugin, ImagePlugin, TablePlugin, SdocLinkPlugin, ParagraphPlugin } from '../plugins';
|
|
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
6
|
import EventBus from '../../utils/event-bus';
|
|
7
7
|
import { INTERNAL_EVENT } from '../../constants';
|
|
8
8
|
var CustomElement = function CustomElement(props) {
|
|
@@ -131,6 +131,12 @@ var CustomElement = function CustomElement(props) {
|
|
|
131
131
|
renderSdocLink = _SdocLinkPlugin$rende[0];
|
|
132
132
|
return renderSdocLink(props, editor);
|
|
133
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
|
+
}
|
|
134
140
|
default:
|
|
135
141
|
{
|
|
136
142
|
var _ParagraphPlugin$rend2 = _slicedToArray(ParagraphPlugin.renderElements, 1),
|
|
@@ -8,6 +8,7 @@ import TableMenu from '../../../plugins/table/menu/table-menu';
|
|
|
8
8
|
import LinkMenu from '../../../plugins/link/menu';
|
|
9
9
|
import CodeBlockMenu from '../../../plugins/code-block/menu';
|
|
10
10
|
import SdocLinkMenu from '../../../plugins/sdoc-link/menu';
|
|
11
|
+
import FileLinkMenu from '../../../plugins/file-link/menu';
|
|
11
12
|
import EventBus from '../../../../utils/event-bus';
|
|
12
13
|
import './index.css';
|
|
13
14
|
var InsertToolbar = function InsertToolbar(_ref) {
|
|
@@ -85,7 +86,7 @@ var InsertToolbar = function InsertToolbar(_ref) {
|
|
|
85
86
|
}
|
|
86
87
|
}, /*#__PURE__*/React.createElement(ImageMenu, props), /*#__PURE__*/React.createElement(TableMenu, props), /*#__PURE__*/React.createElement(LinkMenu, props), /*#__PURE__*/React.createElement(CodeBlockMenu, props), /*#__PURE__*/React.createElement("div", {
|
|
87
88
|
className: "sdoc-dropdown-menu-divider"
|
|
88
|
-
}), /*#__PURE__*/React.createElement(SdocLinkMenu, props))));
|
|
89
|
+
}), /*#__PURE__*/React.createElement(SdocLinkMenu, props), /*#__PURE__*/React.createElement(FileLinkMenu, props))));
|
|
89
90
|
};
|
|
90
91
|
InsertToolbar.defaultProps = {
|
|
91
92
|
isRichEditor: true,
|
package/dist/context.js
CHANGED
|
@@ -179,9 +179,15 @@ var Context = /*#__PURE__*/function () {
|
|
|
179
179
|
}
|
|
180
180
|
}, {
|
|
181
181
|
key: "getSdocLocalFiles",
|
|
182
|
-
value: function getSdocLocalFiles(p) {
|
|
182
|
+
value: function getSdocLocalFiles(p, type) {
|
|
183
183
|
var docUuid = this.getSetting('docUuid');
|
|
184
|
-
return this.api.getSdocFiles(docUuid, p);
|
|
184
|
+
return this.api.getSdocFiles(docUuid, p, type);
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "getSdocLocalFileId",
|
|
188
|
+
value: function getSdocLocalFileId(p) {
|
|
189
|
+
var docUuid = this.getSetting('docUuid');
|
|
190
|
+
return this.api.getSdocFileId(docUuid, p);
|
|
185
191
|
}
|
|
186
192
|
}, {
|
|
187
193
|
key: "getSdocLocalFileUrl",
|
package/package.json
CHANGED
|
@@ -347,6 +347,7 @@
|
|
|
347
347
|
"Icon_and_text_Link": "Icon and text Link",
|
|
348
348
|
"Card": "Card",
|
|
349
349
|
"Select_sdoc_document": "Select sdoc document",
|
|
350
|
+
"Select_file": "Select file",
|
|
350
351
|
"Local_file": "Local file",
|
|
351
352
|
"Internal_server_exec_operations_error": "An exception occurred on the server, please refresh the page and try again",
|
|
352
353
|
"Failed_to_sync_with_server_operations": "Synchronization with the server failed, please refresh the page",
|
|
@@ -362,5 +363,6 @@
|
|
|
362
363
|
"No_changes": "No changes",
|
|
363
364
|
"Title": "Title",
|
|
364
365
|
"Subtitle": "Subtitle",
|
|
365
|
-
"Link_sdoc": "Link sdoc"
|
|
366
|
+
"Link_sdoc": "Link sdoc",
|
|
367
|
+
"Link_file": "Link file"
|
|
366
368
|
}
|
|
@@ -347,6 +347,7 @@
|
|
|
347
347
|
"Icon_and_text_Link": "图标+文字链",
|
|
348
348
|
"Card": "卡片",
|
|
349
349
|
"Select_sdoc_document": "选择 sdoc 文档",
|
|
350
|
+
"Select_file": "选择文件",
|
|
350
351
|
"Local_file": "本地文件",
|
|
351
352
|
"Internal_server_exec_operations_error": "在服务器执行操作异常,请刷新页面后重试",
|
|
352
353
|
"Failed_to_sync_with_server_operations": "与服务器同步操作失败,请刷新页面",
|
|
Binary file
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<missing-glyph />
|
|
16
16
|
|
|
17
|
+
<glyph glyph-name="sdoc-link-file" unicode="" 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
|
+
|
|
17
19
|
<glyph glyph-name="sdoc-sm-close" unicode="" 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" />
|
|
18
20
|
|
|
19
21
|
<glyph glyph-name="sdoc-merge-cell" unicode="" d="M480 896v-288h-96V800H96v-832h288v192h96v-288H0V896h480zM313.6 528L480 384l-166.4-144v96H160v92.8h153.6v99.2zM1024 896v-1024H544v288h96v-192h288V800h-288v-192h-96V896h480z m-313.6-368v-99.2H864v-92.8h-153.6v-96L544 384l166.4 144z" horiz-adv-x="1024" />
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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=
|
|
4
|
-
src: url('./sdoc-editor-font/iconfont.eot?t=
|
|
5
|
-
url('./sdoc-editor-font/iconfont.woff2?t=
|
|
6
|
-
url('./sdoc-editor-font/iconfont.woff?t=
|
|
7
|
-
url('./sdoc-editor-font/iconfont.ttf?t=
|
|
8
|
-
url('./sdoc-editor-font/iconfont.svg?t=
|
|
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');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.sdocfont {
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
-moz-osx-font-smoothing: grayscale;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
.sdoc-link-file:before {
|
|
20
|
+
content: "\e654";
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
.sdoc-sm-close:before {
|
|
20
24
|
content: "\e655";
|
|
21
25
|
}
|