@seafile/sdoc-editor 0.2.13 → 0.2.15
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 +6 -0
- package/dist/basic-sdk/assets/css/sdoc-editor-plugins.css +26 -0
- package/dist/basic-sdk/comment/comment/comment-item-content.js +5 -10
- package/dist/basic-sdk/comment/comment/comment-list.css +6 -10
- package/dist/basic-sdk/extension/commons/color-menu/index.js +1 -1
- package/dist/basic-sdk/extension/commons/menu/menu-item.js +1 -1
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.css +0 -18
- package/dist/basic-sdk/extension/plugins/code-block/hover-menu/index.js +27 -9
- package/dist/basic-sdk/extension/plugins/code-block/render-elem.js +3 -2
- package/dist/basic-sdk/extension/plugins/font/menu/font-family/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/font-size-scale.js +1 -1
- package/dist/basic-sdk/extension/plugins/font/menu/font-size/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/header/menu/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/image/hover-menu/index.js +18 -2
- package/dist/basic-sdk/extension/plugins/image/render-elem.js +69 -22
- package/dist/basic-sdk/extension/plugins/table/helpers.js +60 -0
- package/dist/basic-sdk/index.js +2 -2
- package/dist/basic-sdk/node-id/index.js +3 -2
- package/dist/basic-sdk/outline/index.js +2 -2
- package/dist/basic-sdk/utils/document-utils.js +11 -1
- package/dist/basic-sdk/views/index.js +2 -1
- package/dist/basic-sdk/views/published-revision-diff-viewer.js +59 -0
- package/dist/components/doc-info/index.js +4 -1
- package/dist/components/doc-operations/index.js +2 -1
- package/dist/components/doc-operations/revision-operations/changes-count/index.js +1 -1
- package/dist/components/doc-operations/revision-operations/index.js +2 -2
- package/dist/components/doc-operations/revision-operations/view-changes/index.js +3 -4
- package/dist/components/tooltip/index.js +31 -0
- package/dist/context.js +6 -0
- package/dist/hooks/use-document.js +8 -1
- package/dist/index.js +2 -1
- package/dist/pages/published-revision-viewer.js +92 -0
- package/dist/pages/simple-editor.js +2 -37
- package/dist/utils/index.js +38 -0
- package/package.json +1 -2
- package/public/locales/cs/sdoc-editor.json +2 -1
- package/public/locales/de/sdoc-editor.json +2 -1
- package/public/locales/en/sdoc-editor.json +5 -1
- package/public/locales/es/sdoc-editor.json +2 -1
- package/public/locales/fr/sdoc-editor.json +2 -1
- package/public/locales/it/sdoc-editor.json +2 -1
- package/public/locales/ru/sdoc-editor.json +2 -1
- package/public/locales/zh_CN/sdoc-editor.json +5 -1
- 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/commons/tooltip/index.js +0 -21
- /package/dist/{basic-sdk/extension/commons → components}/tooltip/index.css +0 -0
package/dist/api/seafile-api.js
CHANGED
|
@@ -110,6 +110,12 @@ var SeafileAPI = /*#__PURE__*/function () {
|
|
|
110
110
|
var url = 'api/v2.1/seadoc/revision/base-version-content/' + docUuid + '/';
|
|
111
111
|
return this.req.get(url);
|
|
112
112
|
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "getPublishedRevisionContent",
|
|
115
|
+
value: function getPublishedRevisionContent(docUuid) {
|
|
116
|
+
var url = 'api/v2.1/seadoc/revision/published-content/' + docUuid + '/';
|
|
117
|
+
return this.req.get(url);
|
|
118
|
+
}
|
|
113
119
|
|
|
114
120
|
// local files
|
|
115
121
|
}, {
|
|
@@ -48,6 +48,32 @@
|
|
|
48
48
|
display: inline-block;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
.sdoc-editor-container .article .sdoc-image-content {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
align-items: start;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sdoc-editor-container .article .sdoc-image-content :first-child {
|
|
58
|
+
position: relative;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sdoc-editor-container .article .sdoc-image-content .sdoc-image-caption-input-wrapper {
|
|
62
|
+
border: 0;
|
|
63
|
+
outline: none;
|
|
64
|
+
margin-top: 8px;
|
|
65
|
+
color: #8A8F8D;
|
|
66
|
+
background-color: transparent;
|
|
67
|
+
text-align: center;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
text-overflow: ellipsis;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sdoc-editor-container .article .sdoc-image-content .sdoc-image-caption-input-wrapper::placeholder {
|
|
74
|
+
color: #bec0bf
|
|
75
|
+
}
|
|
76
|
+
|
|
51
77
|
.sdoc-editor-container .article .image-selected {
|
|
52
78
|
box-shadow: 0 0 0 2px #007bff;
|
|
53
79
|
}
|
|
@@ -2,9 +2,10 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import { withTranslation } from 'react-i18next';
|
|
5
|
-
import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle
|
|
5
|
+
import { Dropdown, DropdownItem, DropdownMenu, DropdownToggle } from 'reactstrap';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import CommentEditor from './comment-editor';
|
|
8
|
+
import Tooltip from '../../../components/tooltip';
|
|
8
9
|
var CommentItem = function CommentItem(_ref) {
|
|
9
10
|
var isActive = _ref.isActive,
|
|
10
11
|
container = _ref.container,
|
|
@@ -82,19 +83,13 @@ var CommentItem = function CommentItem(_ref) {
|
|
|
82
83
|
}, dayjs(comment.updated_at).format('MM-DD HH:mm')))), isActive && /*#__PURE__*/React.createElement("div", {
|
|
83
84
|
className: "d-flex"
|
|
84
85
|
}, !comment.resolved && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
id: "tooltip_".concat(menuId),
|
|
85
87
|
className: "comment-operation mr-2",
|
|
86
88
|
onClick: markAsResolved
|
|
87
89
|
}, /*#__PURE__*/React.createElement("i", {
|
|
88
|
-
id: "tooltip_".concat(menuId),
|
|
89
90
|
className: "sdocfont sdoc-confirm"
|
|
90
|
-
})), /*#__PURE__*/React.createElement(
|
|
91
|
-
target: "tooltip_".concat(menuId)
|
|
92
|
-
delay: {
|
|
93
|
-
show: 0,
|
|
94
|
-
hide: 0
|
|
95
|
-
},
|
|
96
|
-
fade: false,
|
|
97
|
-
placement: "bottom"
|
|
91
|
+
})), /*#__PURE__*/React.createElement(Tooltip, {
|
|
92
|
+
target: "tooltip_".concat(menuId)
|
|
98
93
|
}, t('Resolved_tip'))), /*#__PURE__*/React.createElement(Dropdown, {
|
|
99
94
|
isOpen: isDropdownOpen,
|
|
100
95
|
toggle: function toggle() {
|
|
@@ -103,25 +103,21 @@
|
|
|
103
103
|
line-height: 16px;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
.sdoc-comment-list-container .comment-header .comment-operation {
|
|
107
|
-
line-height: 20px;
|
|
108
|
-
font-size: 20px;
|
|
109
|
-
color: rgb(70, 77, 90);
|
|
110
|
-
width: 20px;
|
|
111
|
-
height: 20px;
|
|
112
|
-
cursor: pointer;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
106
|
.sdoc-comment-list-container .comment-ui-container .comment-operation {
|
|
116
107
|
width: 32px;
|
|
117
108
|
height: 32px;
|
|
109
|
+
padding: 0 !important;
|
|
118
110
|
display: flex;
|
|
119
111
|
align-items: center;
|
|
120
112
|
justify-content: center;
|
|
113
|
+
border-radius: 50%;
|
|
114
|
+
background-color: #fff;
|
|
115
|
+
color: rgb(70, 77, 90);
|
|
116
|
+
overflow: hidden;
|
|
121
117
|
}
|
|
122
118
|
|
|
123
119
|
.sdoc-comment-list-container .comment-ui-container.active .comment-operation:hover {
|
|
124
|
-
|
|
120
|
+
cursor: pointer;
|
|
125
121
|
background-color: #f0f0f0;
|
|
126
122
|
}
|
|
127
123
|
|
|
@@ -8,7 +8,7 @@ import { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST } from '../..
|
|
|
8
8
|
import { LocalStorage } from '../../../../utils';
|
|
9
9
|
import { eventStopPropagation } from '../../../utils/mouse-event';
|
|
10
10
|
import ColorItem from './color-item';
|
|
11
|
-
import Tooltip from '
|
|
11
|
+
import Tooltip from '../../../../components/tooltip';
|
|
12
12
|
import './index.css';
|
|
13
13
|
var ColorMenu = function ColorMenu(_ref) {
|
|
14
14
|
var iconClass = _ref.iconClass,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import Tooltip from '
|
|
3
|
+
import Tooltip from '../../../../components/tooltip';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { SDOC_LINK } from '../../constants';
|
|
6
6
|
var MenuItem = function MenuItem(_ref) {
|
|
@@ -75,24 +75,6 @@
|
|
|
75
75
|
background: #f2f2f2;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.sdoc-code-block-hover-menu-container .hover-menu-container .op-tooltip:hover::after {
|
|
79
|
-
position: absolute;
|
|
80
|
-
color: #212529;
|
|
81
|
-
content: attr(op-item-tooltip);
|
|
82
|
-
top: -40px;
|
|
83
|
-
left: -20px;
|
|
84
|
-
width: 70px;
|
|
85
|
-
height: 30px;
|
|
86
|
-
display: flex;
|
|
87
|
-
justify-content: center;
|
|
88
|
-
align-items: center;
|
|
89
|
-
background-color: #fff;
|
|
90
|
-
border-radius: 3px;
|
|
91
|
-
border: 1px solid #e8e8e8;
|
|
92
|
-
font-size: 12px;
|
|
93
|
-
box-shadow: 0 0 5px #ccc;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
78
|
.sdoc-code-block-hover-menu-container .icon-font {
|
|
97
79
|
font-size: 12px;
|
|
98
80
|
color: #444;
|
|
@@ -2,6 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { Input } from 'reactstrap';
|
|
4
4
|
import { withTranslation } from 'react-i18next';
|
|
5
|
+
import Tooltip from '../../../../../components/tooltip';
|
|
5
6
|
import { ElementPopover } from '../../../commons/';
|
|
6
7
|
import { genCodeLangs } from '../prismjs';
|
|
7
8
|
import { getSelectedLangOption } from '../helpers';
|
|
@@ -29,6 +30,10 @@ var CodeBlockHoverMenu = function CodeBlockHoverMenu(_ref) {
|
|
|
29
30
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
30
31
|
langsData = _useState6[0],
|
|
31
32
|
setLangsData = _useState6[1];
|
|
33
|
+
var _useState7 = useState(false),
|
|
34
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
35
|
+
isShowTooltip = _useState8[0],
|
|
36
|
+
setIsShowTooltip = _useState8[1];
|
|
32
37
|
var onHiddenLangsList = useCallback(function (e) {
|
|
33
38
|
if (!e.target.parentNode.className.includes('sdoc-search-langs')) {
|
|
34
39
|
setIsShowlangsList(false);
|
|
@@ -36,6 +41,7 @@ var CodeBlockHoverMenu = function CodeBlockHoverMenu(_ref) {
|
|
|
36
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
42
|
}, []);
|
|
38
43
|
useEffect(function () {
|
|
44
|
+
setIsShowTooltip(true);
|
|
39
45
|
window.addEventListener('click', onHiddenLangsList);
|
|
40
46
|
return function () {
|
|
41
47
|
window.removeEventListener('click', onHiddenLangsList);
|
|
@@ -103,37 +109,49 @@ var CodeBlockHoverMenu = function CodeBlockHoverMenu(_ref) {
|
|
|
103
109
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
104
110
|
className: "sdoc-code-block-hover-operation-divider"
|
|
105
111
|
}), /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
id: "sdoc_code_block_auto_wrap",
|
|
106
113
|
className: "sdoc-code-block-hover-operation-item"
|
|
107
114
|
}, /*#__PURE__*/React.createElement("div", {
|
|
108
115
|
role: "button",
|
|
109
|
-
className: "op-item ".concat(white_space === 'normal' ? 'active' : ''
|
|
110
|
-
"op-item-tooltip": t('Auto_wrap'),
|
|
116
|
+
className: "op-item ".concat(white_space === 'normal' ? 'active' : ''),
|
|
111
117
|
onClick: onAutoLineWrap
|
|
112
118
|
}, /*#__PURE__*/React.createElement("i", {
|
|
113
119
|
className: "sdocfont sdoc-auto-linefeed icon-font"
|
|
114
|
-
}))
|
|
120
|
+
})), isShowTooltip && /*#__PURE__*/React.createElement(Tooltip, {
|
|
121
|
+
target: "sdoc_code_block_auto_wrap",
|
|
122
|
+
placement: "top",
|
|
123
|
+
fade: true
|
|
124
|
+
}, t('Auto_wrap'))), /*#__PURE__*/React.createElement("div", {
|
|
115
125
|
className: "sdoc-code-block-hover-operation-divider"
|
|
116
126
|
}), /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
id: "sdoc_code_block_copy",
|
|
117
128
|
className: "sdoc-code-block-hover-operation-item"
|
|
118
129
|
}, /*#__PURE__*/React.createElement("div", {
|
|
119
130
|
role: "button",
|
|
120
|
-
className: "op-item
|
|
121
|
-
"op-item-tooltip": t('Copy'),
|
|
131
|
+
className: "op-item",
|
|
122
132
|
onClick: onCopyCodeBlock
|
|
123
133
|
}, /*#__PURE__*/React.createElement("i", {
|
|
124
134
|
className: "sdocfont sdoc-copy icon-font"
|
|
125
|
-
}))
|
|
135
|
+
})), isShowTooltip && /*#__PURE__*/React.createElement(Tooltip, {
|
|
136
|
+
target: "sdoc_code_block_copy",
|
|
137
|
+
placement: "top",
|
|
138
|
+
fade: true
|
|
139
|
+
}, t('Copy'))), /*#__PURE__*/React.createElement("div", {
|
|
126
140
|
className: "sdoc-code-block-hover-operation-divider"
|
|
127
141
|
}), /*#__PURE__*/React.createElement("div", {
|
|
142
|
+
id: "sdoc_code_block_delete",
|
|
128
143
|
className: "sdoc-code-block-hover-operation-item"
|
|
129
144
|
}, /*#__PURE__*/React.createElement("div", {
|
|
130
145
|
role: "button",
|
|
131
|
-
className: "op-item
|
|
132
|
-
"op-item-tooltip": t('Delete'),
|
|
146
|
+
className: "op-item",
|
|
133
147
|
onClick: onDelete
|
|
134
148
|
}, /*#__PURE__*/React.createElement("i", {
|
|
135
149
|
className: "sdocfont sdoc-delete icon-font"
|
|
136
|
-
}))
|
|
150
|
+
})), isShowTooltip && /*#__PURE__*/React.createElement(Tooltip, {
|
|
151
|
+
target: "sdoc_code_block_delete",
|
|
152
|
+
placement: "top",
|
|
153
|
+
fade: true
|
|
154
|
+
}, t('Delete'))), isShowlangsList && /*#__PURE__*/React.createElement("div", {
|
|
137
155
|
className: "sdoc-langs-list-container"
|
|
138
156
|
}, /*#__PURE__*/React.createElement("div", {
|
|
139
157
|
className: "sdoc-search-langs"
|
|
@@ -119,8 +119,9 @@ var CodeBlock = function CodeBlock(_ref) {
|
|
|
119
119
|
};
|
|
120
120
|
}, [onScroll, readOnly, scrollRef]);
|
|
121
121
|
var onHiddenHoverMenu = useCallback(function () {
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
if (codeBlockRef.current) {
|
|
123
|
+
setShowHoverMenu(false);
|
|
124
|
+
}
|
|
124
125
|
}, []);
|
|
125
126
|
useEffect(function () {
|
|
126
127
|
var eventBus = EventBus.getInstance();
|
|
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import classnames from 'classnames';
|
|
7
7
|
import { isMenuDisabled, getFont, setFont } from '../../helpers';
|
|
8
8
|
import { FONT, RECENT_USED_FONTS_KEY, DEFAULT_FONT } from '../../../../constants';
|
|
9
|
-
import Tooltip from '
|
|
9
|
+
import Tooltip from '../../../../../../components/tooltip';
|
|
10
10
|
import LocalStorage from '../../../../../../utils/local-storage-utils';
|
|
11
11
|
import context from '../../../../../../context';
|
|
12
12
|
import FontItem from './font-item';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import Tooltip from '
|
|
3
|
+
import Tooltip from '../../../../../../components/tooltip';
|
|
4
4
|
var FontSizeScale = function FontSizeScale(_ref) {
|
|
5
5
|
var children = _ref.children,
|
|
6
6
|
id = _ref.id,
|
|
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
import { isMenuDisabled, getFontSize, setFontSize } from '../../helpers';
|
|
7
7
|
import { FONT_SIZE } from '../../../../constants';
|
|
8
|
-
import Tooltip from '
|
|
8
|
+
import Tooltip from '../../../../../../components/tooltip';
|
|
9
9
|
import './index.css';
|
|
10
10
|
var FontSize = function FontSize(_ref) {
|
|
11
11
|
var isRichEditor = _ref.isRichEditor,
|
|
@@ -8,7 +8,7 @@ import { withTranslation } from 'react-i18next';
|
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
import { getHeaderType, isMenuDisabled, setHeaderType } from '../helpers';
|
|
10
10
|
import { HEADERS, HEADER_TITLE_MAP, MAC_HOTKEYS, PARAGRAPH, SDOC_FONT_SIZE, SUBTITLE, TITLE, WIN_HOTKEYS } from '../../../constants';
|
|
11
|
-
import Tooltip from '
|
|
11
|
+
import Tooltip from '../../../../../components/tooltip';
|
|
12
12
|
import { focusEditor } from '../../../core';
|
|
13
13
|
import './style.css';
|
|
14
14
|
var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
@@ -6,7 +6,7 @@ import { ReactEditor } from '@seafile/slate-react';
|
|
|
6
6
|
import { withTranslation } from 'react-i18next';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
8
|
import { ElementPopover } from '../../../commons';
|
|
9
|
-
import Tooltip from '
|
|
9
|
+
import Tooltip from '../../../../../components/tooltip';
|
|
10
10
|
import ImagePreviewer from '../dialogs/image-previewer';
|
|
11
11
|
import { getImageURL } from '../helpers';
|
|
12
12
|
import { IMAGE_DISPLAY_TYPE, IMAGE_BORDER_TYPE } from '../constants';
|
|
@@ -17,6 +17,7 @@ var ImageHoverMenu = function ImageHoverMenu(_ref) {
|
|
|
17
17
|
menuPosition = _ref.menuPosition,
|
|
18
18
|
element = _ref.element,
|
|
19
19
|
onHideImageHoverMenu = _ref.onHideImageHoverMenu,
|
|
20
|
+
onShowCaption = _ref.onShowCaption,
|
|
20
21
|
t = _ref.t;
|
|
21
22
|
var data = element.data,
|
|
22
23
|
_element$display_type = element.display_type,
|
|
@@ -116,7 +117,22 @@ var ImageHoverMenu = function ImageHoverMenu(_ref) {
|
|
|
116
117
|
target: "sdoc_image_border",
|
|
117
118
|
placement: "top",
|
|
118
119
|
fade: true
|
|
119
|
-
}, t('Image_border')))
|
|
120
|
+
}, t('Image_border'))), display_type === IMAGE_DISPLAY_TYPE[1] && /*#__PURE__*/React.createElement("span", {
|
|
121
|
+
id: "sdoc_image_caption",
|
|
122
|
+
role: "button",
|
|
123
|
+
className: classnames('op-item', 'ml-1', {
|
|
124
|
+
'active': (data === null || data === void 0 ? void 0 : data.caption.length) !== 0
|
|
125
|
+
}),
|
|
126
|
+
onClick: function onClick() {
|
|
127
|
+
onShowCaption();
|
|
128
|
+
}
|
|
129
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
130
|
+
className: "sdocfont sdoc-describe icon-font mr-1"
|
|
131
|
+
}), isShowTooltip && /*#__PURE__*/React.createElement(Tooltip, {
|
|
132
|
+
target: "sdoc_image_caption",
|
|
133
|
+
placement: "top",
|
|
134
|
+
fade: true
|
|
135
|
+
}, t('Insert_caption')))), /*#__PURE__*/React.createElement("span", {
|
|
120
136
|
className: "op-group-item"
|
|
121
137
|
}, /*#__PURE__*/React.createElement("span", {
|
|
122
138
|
id: "sdoc_image_full_screen_mode",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import React, { useState, useCallback, useRef, useEffect } from 'react';
|
|
4
|
-
import { useSelected, useReadOnly } from '@seafile/slate-react';
|
|
4
|
+
import { ReactEditor, useSelected, useReadOnly } from '@seafile/slate-react';
|
|
5
|
+
import { Transforms } from '@seafile/slate';
|
|
5
6
|
import classNames from 'classnames';
|
|
6
7
|
import { withTranslation } from 'react-i18next';
|
|
7
8
|
import { getImageURL, updateImage } from './helpers';
|
|
@@ -27,9 +28,10 @@ var Image = function Image(_ref) {
|
|
|
27
28
|
border_type = _element$border_type === void 0 ? IMAGE_BORDER_TYPE[0].type : _element$border_type;
|
|
28
29
|
var imageWrapStyle = {
|
|
29
30
|
display: display_type === 'Block' ? 'block' : 'inline-block',
|
|
31
|
+
paddingTop: display_type === 'Block' ? '8px' : '',
|
|
30
32
|
textAlign: display_type === 'Block' ? align : ''
|
|
31
33
|
};
|
|
32
|
-
var
|
|
34
|
+
var imageStyle = {
|
|
33
35
|
border: IMAGE_BORDER_TYPE.find(function (item) {
|
|
34
36
|
return item.type === border_type;
|
|
35
37
|
}).value
|
|
@@ -58,6 +60,14 @@ var Image = function Image(_ref) {
|
|
|
58
60
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
59
61
|
menuPosition = _useState10[0],
|
|
60
62
|
setMenuPosition = _useState10[1];
|
|
63
|
+
var _useState11 = useState((data === null || data === void 0 ? void 0 : data.caption) || ''),
|
|
64
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
65
|
+
caption = _useState12[0],
|
|
66
|
+
setCaption = _useState12[1];
|
|
67
|
+
var _useState13 = useState(false),
|
|
68
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
69
|
+
isShowCaption = _useState14[0],
|
|
70
|
+
setIsShowCaption = _useState14[1];
|
|
61
71
|
var registerEvent = useCallback(function (eventList) {
|
|
62
72
|
eventList.forEach(function (element) {
|
|
63
73
|
document.addEventListener(element.eventName, element.event);
|
|
@@ -92,12 +102,19 @@ var Image = function Image(_ref) {
|
|
|
92
102
|
width: imageRef.current.width
|
|
93
103
|
});
|
|
94
104
|
updateImage(editor, newData);
|
|
95
|
-
|
|
105
|
+
|
|
106
|
+
// Reset hover menu position
|
|
107
|
+
setTimeout(function () {
|
|
108
|
+
setIsResizing(false);
|
|
109
|
+
setIsShowImageHoverMenu(true);
|
|
110
|
+
setPosition();
|
|
111
|
+
}, 100);
|
|
96
112
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
|
-
}, [editor, element.data]);
|
|
113
|
+
}, [editor, element.data, imageRef.current]);
|
|
98
114
|
var onResizeStart = useCallback(function (event) {
|
|
99
115
|
event.preventDefault();
|
|
100
116
|
event.stopPropagation();
|
|
117
|
+
setIsShowImageHoverMenu(false);
|
|
101
118
|
setIsResizing(true);
|
|
102
119
|
registerEvent([{
|
|
103
120
|
'eventName': 'mousemove',
|
|
@@ -115,15 +132,16 @@ var Image = function Image(_ref) {
|
|
|
115
132
|
};
|
|
116
133
|
}, [element.data, movingWidth]);
|
|
117
134
|
var onScroll = useCallback(function () {
|
|
118
|
-
setPosition(
|
|
135
|
+
setPosition();
|
|
119
136
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
120
137
|
}, []);
|
|
121
138
|
var onHideImageHoverMenu = useCallback(function (e) {
|
|
122
139
|
var _imagePreviewer$;
|
|
140
|
+
if (isResizing) return;
|
|
123
141
|
var imagePreviewer = document.getElementsByClassName('sf-editor-image-previewer');
|
|
124
142
|
if (e.target === imageRef.current || ((_imagePreviewer$ = imagePreviewer[0]) === null || _imagePreviewer$ === void 0 ? void 0 : _imagePreviewer$.contains(e.target))) return;
|
|
125
143
|
setIsShowImageHoverMenu(false);
|
|
126
|
-
}, []);
|
|
144
|
+
}, [isResizing]);
|
|
127
145
|
useEffect(function () {
|
|
128
146
|
var observerRefValue = null;
|
|
129
147
|
if (isShowImageHoverMenu) {
|
|
@@ -151,23 +169,19 @@ var Image = function Image(_ref) {
|
|
|
151
169
|
};
|
|
152
170
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
153
171
|
}, [isShowImageHoverMenu, onHideImageHoverMenu]);
|
|
154
|
-
var setPosition = useCallback(function (
|
|
155
|
-
if (
|
|
156
|
-
var
|
|
157
|
-
top =
|
|
158
|
-
left =
|
|
159
|
-
width = _elem$getBoundingClie.width;
|
|
160
|
-
var menuTop = top - 42;
|
|
161
|
-
var menuLeft = left - 222 / 2 + width / 2; // left = left distance - (menu width / 2) + (image with / 2)
|
|
172
|
+
var setPosition = useCallback(function () {
|
|
173
|
+
if (imageRef.current) {
|
|
174
|
+
var _imageRef$current$get = imageRef.current.getBoundingClientRect(),
|
|
175
|
+
top = _imageRef$current$get.top,
|
|
176
|
+
left = _imageRef$current$get.left;
|
|
162
177
|
setMenuPosition({
|
|
163
|
-
top:
|
|
164
|
-
left:
|
|
178
|
+
top: top - 42,
|
|
179
|
+
left: left - 3
|
|
165
180
|
});
|
|
166
181
|
}
|
|
167
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
182
|
}, []);
|
|
169
183
|
var onClickImage = useCallback(function (e) {
|
|
170
|
-
setPosition(
|
|
184
|
+
setPosition();
|
|
171
185
|
setIsShowImageHoverMenu(true);
|
|
172
186
|
}, [setPosition]);
|
|
173
187
|
var reloadImage = useCallback(function () {
|
|
@@ -184,6 +198,19 @@ var Image = function Image(_ref) {
|
|
|
184
198
|
}
|
|
185
199
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
186
200
|
}, []);
|
|
201
|
+
var onSetCaption = useCallback(function (e) {
|
|
202
|
+
var path = ReactEditor.findPath(editor, element);
|
|
203
|
+
var newData = _objectSpread(_objectSpread({}, data), {}, {
|
|
204
|
+
caption: e.target.value.trim()
|
|
205
|
+
});
|
|
206
|
+
if (path) {
|
|
207
|
+
Transforms.setNodes(editor, {
|
|
208
|
+
data: newData
|
|
209
|
+
}, {
|
|
210
|
+
at: path
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}, [data, editor, element]);
|
|
187
214
|
return /*#__PURE__*/React.createElement(React.Fragment, null, isShowImagePlaceholder && /*#__PURE__*/React.createElement("span", Object.assign({
|
|
188
215
|
className: classNames('sdoc-image-wrapper', className)
|
|
189
216
|
}, attributes), /*#__PURE__*/React.createElement("img", {
|
|
@@ -197,13 +224,16 @@ var Image = function Image(_ref) {
|
|
|
197
224
|
}, attributes, {
|
|
198
225
|
style: imageWrapStyle
|
|
199
226
|
}), /*#__PURE__*/React.createElement("span", {
|
|
200
|
-
className: "sdoc-image-inner"
|
|
201
|
-
|
|
202
|
-
|
|
227
|
+
className: "sdoc-image-inner"
|
|
228
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
229
|
+
className: "sdoc-image-content"
|
|
230
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
231
|
+
style: imageStyle
|
|
203
232
|
}, /*#__PURE__*/React.createElement("img", {
|
|
204
233
|
className: classNames({
|
|
205
234
|
'image-selected': isSelected
|
|
206
235
|
}),
|
|
236
|
+
onClick: onClickImage,
|
|
207
237
|
ref: imageRef,
|
|
208
238
|
src: getImageURL(data.src),
|
|
209
239
|
style: getImageStyle(),
|
|
@@ -217,12 +247,29 @@ var Image = function Image(_ref) {
|
|
|
217
247
|
}), isResizing && /*#__PURE__*/React.createElement("span", {
|
|
218
248
|
className: "image-size",
|
|
219
249
|
contentEditable: false
|
|
220
|
-
}, /*#__PURE__*/React.createElement("span", null, t('Width'), ':', parseInt(movingWidth || imageRef.current.clientWidth)), /*#__PURE__*/React.createElement("span", null, "\xA0\xA0"), /*#__PURE__*/React.createElement("span", null, t('Height'), ':', imageRef.current.clientHeight))),
|
|
250
|
+
}, /*#__PURE__*/React.createElement("span", null, t('Width'), ':', parseInt(movingWidth || imageRef.current.clientWidth)), /*#__PURE__*/React.createElement("span", null, "\xA0\xA0"), /*#__PURE__*/React.createElement("span", null, t('Height'), ':', imageRef.current.clientHeight))), display_type === 'Block' && (isShowCaption || (data === null || data === void 0 ? void 0 : data.caption)) && /*#__PURE__*/React.createElement("input", {
|
|
251
|
+
className: "sdoc-image-caption-input-wrapper",
|
|
252
|
+
style: {
|
|
253
|
+
width: (data === null || data === void 0 ? void 0 : data.width) || '120px'
|
|
254
|
+
},
|
|
255
|
+
placeholder: t('Insert_caption'),
|
|
256
|
+
value: caption,
|
|
257
|
+
onBlur: onSetCaption,
|
|
258
|
+
onChange: function onChange(e) {
|
|
259
|
+
setCaption(e.target.value.trim());
|
|
260
|
+
},
|
|
261
|
+
onCompositionStart: function onCompositionStart(e) {
|
|
262
|
+
e.stopPropagation();
|
|
263
|
+
}
|
|
264
|
+
}))), children), isShowImageHoverMenu && !readOnly && /*#__PURE__*/React.createElement(ImageHoverMenu, {
|
|
221
265
|
editor: editor,
|
|
222
266
|
menuPosition: menuPosition,
|
|
223
267
|
element: element,
|
|
224
268
|
onHideImageHoverMenu: function onHideImageHoverMenu() {
|
|
225
269
|
setIsShowImageHoverMenu(false);
|
|
270
|
+
},
|
|
271
|
+
onShowCaption: function onShowCaption() {
|
|
272
|
+
setIsShowCaption(true);
|
|
226
273
|
}
|
|
227
274
|
})));
|
|
228
275
|
};
|
|
@@ -878,4 +878,64 @@ export var getRowHeight = function getRowHeight(element, rowIndex) {
|
|
|
878
878
|
style = _element$style === void 0 ? {} : _element$style;
|
|
879
879
|
var rowHeight = style[TABLE_ROW_STYLE.MIN_HEIGHT] || TABLE_ROW_MIN_HEIGHT;
|
|
880
880
|
return rowIndex === 0 ? rowHeight + 1 : rowHeight;
|
|
881
|
+
};
|
|
882
|
+
var normalizeTableCell = function normalizeTableCell(cell) {
|
|
883
|
+
if (!cell) return generateTableCell();
|
|
884
|
+
var newCell = _objectSpread({
|
|
885
|
+
children: [{
|
|
886
|
+
text: '',
|
|
887
|
+
id: slugid.nice()
|
|
888
|
+
}]
|
|
889
|
+
}, cell);
|
|
890
|
+
|
|
891
|
+
// normalize cell children
|
|
892
|
+
var newCellChildren = [];
|
|
893
|
+
newCell.children.forEach(function (cellChild) {
|
|
894
|
+
var cellChildType = cellChild.type;
|
|
895
|
+
if (cellChildType === ELEMENT_TYPE.PARAGRAPH) {
|
|
896
|
+
newCellChildren.push.apply(newCellChildren, _toConsumableArray(cellChild.children));
|
|
897
|
+
} else {
|
|
898
|
+
newCellChildren.push(cellChild);
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
newCell.children = newCellChildren.map(function (item) {
|
|
902
|
+
if (item.BOLD) {
|
|
903
|
+
item.bold = item.BOLD;
|
|
904
|
+
delete item['BOLD'];
|
|
905
|
+
}
|
|
906
|
+
if (item.ITALIC) {
|
|
907
|
+
item.italic = item.ITALIC;
|
|
908
|
+
delete item['ITALIC'];
|
|
909
|
+
}
|
|
910
|
+
return item;
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
// normalize cell style
|
|
914
|
+
if (newCell.data) {
|
|
915
|
+
var cellStyle = _objectSpread({}, newCell.data);
|
|
916
|
+
delete newCell['data'];
|
|
917
|
+
Object.keys(cellStyle).forEach(function (cellStyleKey) {
|
|
918
|
+
if (cellStyleKey === 'align') {
|
|
919
|
+
cellStyle['text_align'] = cellStyle['align'];
|
|
920
|
+
delete cellStyle['align'];
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
newCell.style = cellStyle;
|
|
924
|
+
}
|
|
925
|
+
return newCell;
|
|
926
|
+
};
|
|
927
|
+
export var normalizeTableELement = function normalizeTableELement(editor, element) {
|
|
928
|
+
if (element.type !== ELEMENT_TYPE.TABLE) {
|
|
929
|
+
var size = [element.children.length, element.children[0].children.length];
|
|
930
|
+
return generateEmptyTable(editor, size);
|
|
931
|
+
}
|
|
932
|
+
var newElement = _objectSpread({}, element);
|
|
933
|
+
for (var i = 0; i < element.children.length; i++) {
|
|
934
|
+
var row = newElement.children[i];
|
|
935
|
+
for (var j = 0; j < row.children.length; j++) {
|
|
936
|
+
row.children[j] = normalizeTableCell(row.children[j]);
|
|
937
|
+
}
|
|
938
|
+
newElement.children[i] = row;
|
|
939
|
+
}
|
|
940
|
+
return newElement;
|
|
881
941
|
};
|
package/dist/basic-sdk/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SDocEditor from './editor/sdoc-editor';
|
|
2
|
-
import { DiffViewer, SDocViewer } from './views';
|
|
2
|
+
import { DiffViewer, SDocViewer, PublishedRevisionDiffViewer } from './views';
|
|
3
3
|
import SDocOutline from './outline';
|
|
4
4
|
import EventBus from './utils/event-bus';
|
|
5
|
-
export { SDocEditor, SDocViewer, SDocOutline, EventBus, DiffViewer };
|
|
5
|
+
export { SDocEditor, SDocViewer, SDocOutline, EventBus, DiffViewer, PublishedRevisionDiffViewer };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decorateOperation, replacePastedDataId } from './helpers';
|
|
2
|
-
import { getSlateFragmentAttribute } from '../utils/document-utils';
|
|
2
|
+
import { getSlateFragmentAttribute, normalizeCopyNodes } from '../utils/document-utils';
|
|
3
3
|
import { CLIPBOARD_FORMAT_KEY } from '../extension/constants';
|
|
4
4
|
var withNodeId = function withNodeId(editor) {
|
|
5
5
|
var apply = editor.apply;
|
|
@@ -16,7 +16,8 @@ var withNodeId = function withNodeId(editor) {
|
|
|
16
16
|
var decoded = decodeURIComponent(window.atob(fragment));
|
|
17
17
|
var parsed = JSON.parse(decoded);
|
|
18
18
|
var newData = replacePastedDataId(parsed);
|
|
19
|
-
newEditor
|
|
19
|
+
var normalizeNewData = normalizeCopyNodes(newEditor, newData);
|
|
20
|
+
newEditor.insertFragment(normalizeNewData);
|
|
20
21
|
return newEditor;
|
|
21
22
|
}
|
|
22
23
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { withTranslation } from 'react-i18next';
|
|
4
|
-
import { UncontrolledTooltip } from 'reactstrap';
|
|
5
4
|
import { INTERNAL_EVENT } from '../constants';
|
|
6
5
|
import EventBus from '../utils/event-bus';
|
|
7
6
|
import OutlineItem from './outline-item';
|
|
7
|
+
import Tooltip from '../../components/tooltip';
|
|
8
8
|
import './style.css';
|
|
9
9
|
export var getOutlineSetting = function getOutlineSetting() {
|
|
10
10
|
var currentValue = localStorage.getItem('sdoc');
|
|
@@ -72,7 +72,7 @@ var SDocOutline = function SDocOutline(_ref) {
|
|
|
72
72
|
id: "sdoc-outline-menu",
|
|
73
73
|
className: "sdoc-outline-menu sdocfont sdoc-table-of-content",
|
|
74
74
|
onClick: toggleShow
|
|
75
|
-
}), /*#__PURE__*/React.createElement(
|
|
75
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
76
76
|
placement: "right",
|
|
77
77
|
target: "sdoc-outline-menu"
|
|
78
78
|
}, t('Outline'))));
|
|
@@ -2,7 +2,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import ObjectUtils from './object-utils';
|
|
3
3
|
import context from '../../context';
|
|
4
4
|
import { generateDefaultText } from '../../basic-sdk/extension/core/utils/index';
|
|
5
|
-
import { CLIPBOARD_ORIGIN_SDOC_KEY } from '../extension/constants';
|
|
5
|
+
import { CLIPBOARD_ORIGIN_SDOC_KEY, ELEMENT_TYPE } from '../extension/constants';
|
|
6
|
+
import { normalizeTableELement } from '../extension/plugins/table/helpers';
|
|
6
7
|
export var normalizeChildren = function normalizeChildren(children) {
|
|
7
8
|
// text
|
|
8
9
|
if (!Array.isArray(children)) return children;
|
|
@@ -19,6 +20,15 @@ export var normalizeChildren = function normalizeChildren(children) {
|
|
|
19
20
|
return child;
|
|
20
21
|
});
|
|
21
22
|
};
|
|
23
|
+
export var normalizeCopyNodes = function normalizeCopyNodes(editor, elements) {
|
|
24
|
+
if (!Array.isArray(elements) || elements.length === 0) return [];
|
|
25
|
+
return elements.map(function (element) {
|
|
26
|
+
if (element.type === ELEMENT_TYPE.TABLE) {
|
|
27
|
+
return normalizeTableELement(editor, element);
|
|
28
|
+
}
|
|
29
|
+
return element;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
22
32
|
export var setOriginSdocKey = function setOriginSdocKey(event) {
|
|
23
33
|
var docUuid = context.getSetting('docUuid');
|
|
24
34
|
event.clipboardData.setData("text/".concat(CLIPBOARD_ORIGIN_SDOC_KEY), docUuid);
|