@seafile/seafile-editor 0.3.76
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/README.md +119 -0
- package/TODO.md +55 -0
- package/dist/components/add-formula-dialog.js +135 -0
- package/dist/components/add-image-dialog.js +78 -0
- package/dist/components/add-link-dialog.js +148 -0
- package/dist/components/comment-dialog.js +107 -0
- package/dist/components/comment-panel.js +452 -0
- package/dist/components/context-menu.js +112 -0
- package/dist/components/detail-list-view.js +119 -0
- package/dist/components/generate-share-link.js +412 -0
- package/dist/components/internal-link-dialog.js +96 -0
- package/dist/components/loading.js +32 -0
- package/dist/components/markdown-lint.js +87 -0
- package/dist/components/modal-portal.js +46 -0
- package/dist/components/outline.js +130 -0
- package/dist/components/participants-list.js +126 -0
- package/dist/components/related-files-list.js +75 -0
- package/dist/components/shortcut-dialog.js +167 -0
- package/dist/components/side-panel.js +175 -0
- package/dist/components/toast/alert.js +150 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/toast.js +179 -0
- package/dist/components/toast/toastManager.js +158 -0
- package/dist/components/toast/toaster.js +76 -0
- package/dist/components/toolbar.js +235 -0
- package/dist/components/topbar-component/button-group.js +31 -0
- package/dist/components/topbar-component/editor-toolbar.js +545 -0
- package/dist/components/topbar-component/file-info.js +65 -0
- package/dist/components/topbar-component/header-list.js +128 -0
- package/dist/components/topbar-component/icon-button.js +99 -0
- package/dist/components/topbar-component/insert-file.js +67 -0
- package/dist/components/topbar-component/table-toolbar.js +175 -0
- package/dist/components/topbar-component/upload-img.js +122 -0
- package/dist/components/user-help.js +205 -0
- package/dist/css/diff-viewer.css +105 -0
- package/dist/css/history-viewer.css +104 -0
- package/dist/css/keyboard-shortcuts.css +59 -0
- package/dist/css/layout.css +110 -0
- package/dist/css/markdown-viewer-slate/file-tags-list.css +76 -0
- package/dist/css/markdown-viewer.css +69 -0
- package/dist/css/plaineditor/markdown-editor.css +12 -0
- package/dist/css/react-mentions-default-style.js +72 -0
- package/dist/css/related-files-list.css +56 -0
- package/dist/css/richeditor/comments-list.css +184 -0
- package/dist/css/richeditor/detail-list-view.css +114 -0
- package/dist/css/richeditor/document-info.css +57 -0
- package/dist/css/richeditor/formula.css +19 -0
- package/dist/css/richeditor/image.css +141 -0
- package/dist/css/richeditor/link.css +7 -0
- package/dist/css/richeditor/navbar-imgbutton.css +79 -0
- package/dist/css/richeditor/participants-list.css +22 -0
- package/dist/css/richeditor/rich-editor-main.css +42 -0
- package/dist/css/richeditor/right-panel.css +84 -0
- package/dist/css/richeditor/side-panel.css +190 -0
- package/dist/css/richeditor/table.css +57 -0
- package/dist/css/richeditor/textlink-hovermenu.css +47 -0
- package/dist/css/richeditor/tree-view.css +67 -0
- package/dist/css/topbar.css +400 -0
- package/dist/editor/code-highlight-package.js +27 -0
- package/dist/editor/controller/block-element-controller.js +376 -0
- package/dist/editor/controller/inline-element-controller.js +129 -0
- package/dist/editor/controller/normalize-controller.js +107 -0
- package/dist/editor/controller/shortcut-controller.js +394 -0
- package/dist/editor/controller/void-element-controller.js +12 -0
- package/dist/editor/custom/custom.js +17 -0
- package/dist/editor/custom/get-event-transfer.js +34 -0
- package/dist/editor/custom/getNodesByTypeAtRange.js +69 -0
- package/dist/editor/custom/insertNodes.js +140 -0
- package/dist/editor/custom/is-empty-paragraph.js +13 -0
- package/dist/editor/custom/set-event-transfer.js +31 -0
- package/dist/editor/custom/split-nodes-at-point.js +162 -0
- package/dist/editor/custom/unwrap-node-by-type-at-range.js +81 -0
- package/dist/editor/editor-component/check-list-item.js +64 -0
- package/dist/editor/editor-component/code-block.js +150 -0
- package/dist/editor/editor-component/formula.js +79 -0
- package/dist/editor/editor-component/image.js +215 -0
- package/dist/editor/editor-component/link.js +11 -0
- package/dist/editor/editor-component/table.js +172 -0
- package/dist/editor/editor-component/textlink-hovermenu.js +136 -0
- package/dist/editor/editor-plugin.js +249 -0
- package/dist/editor/editor-utils/block-element-utils/blockquote-utils.js +96 -0
- package/dist/editor/editor-utils/block-element-utils/code-utils.js +162 -0
- package/dist/editor/editor-utils/block-element-utils/formula-utils.js +58 -0
- package/dist/editor/editor-utils/block-element-utils/index.js +38 -0
- package/dist/editor/editor-utils/block-element-utils/list-utils.js +398 -0
- package/dist/editor/editor-utils/block-element-utils/table-utils.js +418 -0
- package/dist/editor/editor-utils/common-editor-utils.js +587 -0
- package/dist/editor/editor-utils/inline-element-utils/index.js +95 -0
- package/dist/editor/editor-utils/mark-utils.js +25 -0
- package/dist/editor/editor-utils/range-utils.js +9 -0
- package/dist/editor/editor-utils/selection-utils.js +33 -0
- package/dist/editor/editor-utils/text-utils.js +130 -0
- package/dist/editor/editor.js +66 -0
- package/dist/editor/element-model/blockquote.js +16 -0
- package/dist/editor/element-model/image.js +19 -0
- package/dist/editor/element-model/link.js +19 -0
- package/dist/editor/element-model/table.js +50 -0
- package/dist/editor/element-model/text.js +13 -0
- package/dist/editor/load-script.js +83 -0
- package/dist/editor/plain-markdown-editor.js +324 -0
- package/dist/editor/rich-markdown-editor.js +580 -0
- package/dist/editor/seafile-editor.js +326 -0
- package/dist/editor/simple-editor.js +245 -0
- package/dist/editor-api.js +261 -0
- package/dist/index.css +97 -0
- package/dist/lib/slate-hyperscript/creators.js +263 -0
- package/dist/lib/slate-hyperscript/hyperscript.js +92 -0
- package/dist/lib/slate-hyperscript/index.js +3 -0
- package/dist/lib/slate-hyperscript/tokens.js +102 -0
- package/dist/lib/unified/index.js +470 -0
- package/dist/lib/vfile/core.js +172 -0
- package/dist/lib/vfile/index.js +48 -0
- package/dist/seafile-editor-chooser.js +45 -0
- package/dist/seafile-markdown-editor.js +301 -0
- package/dist/seafile-markdown-viewer.js +79 -0
- package/dist/seafile-simple-editor.js +56 -0
- package/dist/utils/copy-to-clipboard.js +47 -0
- package/dist/utils/deserialize-html.js +282 -0
- package/dist/utils/diff/compare-strings.js +46 -0
- package/dist/utils/diff/diff.js +855 -0
- package/dist/utils/diff/index.js +2 -0
- package/dist/utils/render-slate.js +219 -0
- package/dist/utils/seafile-markdown2html.js +62 -0
- package/dist/utils/slate2markdown/deserialize.js +689 -0
- package/dist/utils/slate2markdown/index.js +3 -0
- package/dist/utils/slate2markdown/serialize.js +407 -0
- package/dist/utils/utils.js +28 -0
- package/dist/viewer/diff-viewer.js +98 -0
- package/dist/viewer/markdown-viewer.js +139 -0
- package/dist/viewer/slate-viewer.js +73 -0
- package/dist/viewer/viewer-formula.js +67 -0
- package/dist/viewer/viewer-image.js +93 -0
- package/dist/viewer/viewer-outline.js +118 -0
- package/package.json +215 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +45 -0
- package/public/locales/cs/seafile-editor.json +169 -0
- package/public/locales/de/seafile-editor.json +169 -0
- package/public/locales/en/seafile-editor.json +222 -0
- package/public/locales/es/seafile-editor.json +169 -0
- package/public/locales/es-AR/seafile-editor.json +169 -0
- package/public/locales/es-MX/seafile-editor.json +169 -0
- package/public/locales/fr/seafile-editor.json +169 -0
- package/public/locales/it/seafile-editor.json +169 -0
- package/public/locales/ru/seafile-editor.json +169 -0
- package/public/locales/zh-CN/seafile-editor.json +219 -0
- package/public/manifest.json +15 -0
- package/public/media/scripts/mathjax/tex-svg.js +1 -0
- package/public/media/seafile-editor-font/iconfont.eot +0 -0
- package/public/media/seafile-editor-font/iconfont.svg +164 -0
- package/public/media/seafile-editor-font/iconfont.ttf +0 -0
- package/public/media/seafile-editor-font/iconfont.woff +0 -0
- package/public/media/seafile-editor-font/iconfont.woff2 +0 -0
- package/public/media/seafile-editor-font.css +201 -0
- package/public/media/seafile-logo.png +0 -0
- package/public/media/seafile-ui.css +11169 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { withTranslation } from 'react-i18next';
|
|
7
|
+
import { Utils } from '../../utils/utils';
|
|
8
|
+
import InlineElementUtils from '../editor-utils/inline-element-utils';
|
|
9
|
+
import Modal from '../../components/modal-portal';
|
|
10
|
+
|
|
11
|
+
var Image = /*#__PURE__*/function (_React$Component) {
|
|
12
|
+
_inherits(Image, _React$Component);
|
|
13
|
+
|
|
14
|
+
var _super = _createSuper(Image);
|
|
15
|
+
|
|
16
|
+
function Image(props) {
|
|
17
|
+
var _this;
|
|
18
|
+
|
|
19
|
+
_classCallCheck(this, Image);
|
|
20
|
+
|
|
21
|
+
_this = _super.call(this, props);
|
|
22
|
+
|
|
23
|
+
_this.startMove = function (e) {
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
|
|
26
|
+
_this.setState({
|
|
27
|
+
isResizing: true
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
window.addEventListener('mousemove', _this.handleMove);
|
|
31
|
+
window.addEventListener('mouseup', _this.stopMove);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_this.stopMove = function (e) {
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
window.removeEventListener('mousemove', _this.handleMove);
|
|
38
|
+
var node = _this.props.node;
|
|
39
|
+
|
|
40
|
+
_this.inlineElementUtils.adjustImageSize({
|
|
41
|
+
width: _this.state.width,
|
|
42
|
+
src: node.data.src
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
_this.setState({
|
|
46
|
+
isResizing: false
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
window.removeEventListener('mouseup', _this.stopMove);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
_this.handleMove = function (e) {
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
var changeX;
|
|
56
|
+
changeX = e.clientX - _this.refs.resizer.getBoundingClientRect().left - 5;
|
|
57
|
+
var imageWidth = _this.refs.image.width + changeX;
|
|
58
|
+
|
|
59
|
+
if (imageWidth >= _this.editor.offsetWidth) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (imageWidth < 20) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_this.setState({
|
|
68
|
+
width: imageWidth
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
_this.setFullScreen = function (event) {
|
|
73
|
+
event.stopPropagation();
|
|
74
|
+
var src = _this.props.node.data.src;
|
|
75
|
+
|
|
76
|
+
_this.toggleBigImage(event, src);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
_this.toggleBigImage = function (event, src) {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
|
|
82
|
+
_this.setState({
|
|
83
|
+
isShowBigImage: !_this.state.isShowBigImage
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
_this.imgSrc = src;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
_this.renderBigImage = function () {
|
|
90
|
+
return /*#__PURE__*/React.createElement(BigImage, {
|
|
91
|
+
bigImageSrc: _this.imgSrc,
|
|
92
|
+
toggleBigImage: _this.toggleBigImage
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
_this.state = {
|
|
97
|
+
width: null,
|
|
98
|
+
isResizing: false,
|
|
99
|
+
isShowBigImage: false
|
|
100
|
+
};
|
|
101
|
+
_this.inlineElementUtils = new InlineElementUtils(window.editor);
|
|
102
|
+
return _this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_createClass(Image, [{
|
|
106
|
+
key: "componentDidMount",
|
|
107
|
+
value: function componentDidMount() {
|
|
108
|
+
this.editor = document.querySelector('.editor-component');
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "componentWillUnmount",
|
|
112
|
+
value: function componentWillUnmount() {
|
|
113
|
+
this.refs.resizer = null;
|
|
114
|
+
this.refs.image = null;
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
key: "render",
|
|
118
|
+
value: function render() {
|
|
119
|
+
var _this$props = this.props,
|
|
120
|
+
attributes = _this$props.attributes,
|
|
121
|
+
node = _this$props.node,
|
|
122
|
+
isSelected = _this$props.isSelected,
|
|
123
|
+
children = _this$props.children;
|
|
124
|
+
var isResizing = this.state.isResizing;
|
|
125
|
+
var data = node.data;
|
|
126
|
+
var src = data.src;
|
|
127
|
+
|
|
128
|
+
if (/^\.\.\/*/.test(src) || /^\.\/*/.test(src)) {
|
|
129
|
+
var _window$editor$editor = window.editor.editorApi,
|
|
130
|
+
filePath = _window$editor$editor.filePath,
|
|
131
|
+
serviceUrl = _window$editor$editor.serviceUrl,
|
|
132
|
+
repoID = _window$editor$editor.repoID;
|
|
133
|
+
var originalPath = filePath.slice(0, filePath.lastIndexOf('/')) + '/' + src;
|
|
134
|
+
src = serviceUrl + '/lib/' + repoID + '/file/' + Utils.pathNormalize(originalPath) + '?raw=1';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var dom = /*#__PURE__*/React.createElement("span", Object.assign({
|
|
138
|
+
className: "seafile-ed-image"
|
|
139
|
+
}, attributes), isSelected || isResizing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("img", {
|
|
140
|
+
className: "seafile-ed-image-inResizing",
|
|
141
|
+
draggable: false,
|
|
142
|
+
src: src,
|
|
143
|
+
width: this.state.width || data.width,
|
|
144
|
+
alt: ' ',
|
|
145
|
+
ref: "image"
|
|
146
|
+
}), this.state.isResizing ? /*#__PURE__*/React.createElement("span", {
|
|
147
|
+
contentEditable: false,
|
|
148
|
+
className: "image-size"
|
|
149
|
+
}, /*#__PURE__*/React.createElement("span", null, this.props.t('width'), ':', parseInt(this.state.width || this.refs.image.clientWidth)), /*#__PURE__*/React.createElement("span", null, "\xA0\xA0"), /*#__PURE__*/React.createElement("span", null, this.props.t('height'), ':', this.refs.image.clientHeight)) : null, /*#__PURE__*/React.createElement("span", {
|
|
150
|
+
ref: "resizer",
|
|
151
|
+
onMouseDown: this.startMove,
|
|
152
|
+
className: 'image-resizer'
|
|
153
|
+
}), isSelected && /*#__PURE__*/React.createElement("span", {
|
|
154
|
+
contentEditable: false,
|
|
155
|
+
onClick: this.setFullScreen,
|
|
156
|
+
className: "image-full-button"
|
|
157
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
158
|
+
className: 'iconfont icon-fullscreen'
|
|
159
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
160
|
+
className: 'image-tooltip'
|
|
161
|
+
}, this.props.t('Full_screen')))) : /*#__PURE__*/React.createElement("img", {
|
|
162
|
+
width: data.width || '',
|
|
163
|
+
draggable: false,
|
|
164
|
+
src: src,
|
|
165
|
+
alt: ' ',
|
|
166
|
+
ref: "image"
|
|
167
|
+
}), children, this.state.isShowBigImage && this.renderBigImage());
|
|
168
|
+
return src ? dom : /*#__PURE__*/React.createElement("span", attributes, "Loading...");
|
|
169
|
+
}
|
|
170
|
+
}]);
|
|
171
|
+
|
|
172
|
+
return Image;
|
|
173
|
+
}(React.Component);
|
|
174
|
+
|
|
175
|
+
var BigImage = /*#__PURE__*/function (_React$Component2) {
|
|
176
|
+
_inherits(BigImage, _React$Component2);
|
|
177
|
+
|
|
178
|
+
var _super2 = _createSuper(BigImage);
|
|
179
|
+
|
|
180
|
+
function BigImage() {
|
|
181
|
+
_classCallCheck(this, BigImage);
|
|
182
|
+
|
|
183
|
+
return _super2.apply(this, arguments);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
_createClass(BigImage, [{
|
|
187
|
+
key: "render",
|
|
188
|
+
value: function render() {
|
|
189
|
+
var _this2 = this;
|
|
190
|
+
|
|
191
|
+
return /*#__PURE__*/React.createElement(Modal, null, /*#__PURE__*/React.createElement("div", {
|
|
192
|
+
className: 'big-image-cover',
|
|
193
|
+
onClick: function onClick(event) {
|
|
194
|
+
return _this2.props.toggleBigImage(event);
|
|
195
|
+
}
|
|
196
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
197
|
+
className: 'big-image-container'
|
|
198
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
199
|
+
src: this.props.bigImageSrc,
|
|
200
|
+
alt: ""
|
|
201
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
202
|
+
onClick: function onClick(event) {
|
|
203
|
+
return _this2.props.toggleBigImage(event);
|
|
204
|
+
},
|
|
205
|
+
className: 'image-container-close'
|
|
206
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
207
|
+
className: 'iconfont icon-close'
|
|
208
|
+
}))));
|
|
209
|
+
}
|
|
210
|
+
}]);
|
|
211
|
+
|
|
212
|
+
return BigImage;
|
|
213
|
+
}(React.Component);
|
|
214
|
+
|
|
215
|
+
export default withTranslation('seafile-editor')(Image);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSelected } from '@seafile/slate-react';
|
|
3
|
+
|
|
4
|
+
function Link(props) {
|
|
5
|
+
var className = useSelected() ? 'seafile-ed-hovermenu-mouseclick' : null;
|
|
6
|
+
return /*#__PURE__*/React.createElement("span", Object.assign({}, props.attributes, {
|
|
7
|
+
className: 'virtual-link ' + className
|
|
8
|
+
}), props.children);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default Link;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import '../../css/richeditor/table.css';
|
|
8
|
+
|
|
9
|
+
var TableContainer = /*#__PURE__*/function (_React$PureComponent) {
|
|
10
|
+
_inherits(TableContainer, _React$PureComponent);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(TableContainer);
|
|
13
|
+
|
|
14
|
+
function TableContainer(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, TableContainer);
|
|
18
|
+
|
|
19
|
+
_this = _super.call(this, props);
|
|
20
|
+
|
|
21
|
+
_this.clearSelectedCells = function () {
|
|
22
|
+
_this.table.querySelectorAll('.selected-cell').forEach(function (selectedCell) {
|
|
23
|
+
selectedCell.classList.remove('selected-cell', 'selected-cell-left', 'selected-cell-bottom', 'selected-cell-top', 'selected-cell-right');
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
_this.selectTable = function (event) {
|
|
28
|
+
_this.startRowIndex = _this.getTableElement(event.target, 'tr').rowIndex;
|
|
29
|
+
_this.startColIndex = _this.getTableElement(event.target, 'td').cellIndex;
|
|
30
|
+
window.document.addEventListener('mousemove', _this.selectCellsInTable);
|
|
31
|
+
window.document.addEventListener('mouseup', _this.onMouseUp);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_this.getTableElement = function (node, type) {
|
|
35
|
+
if (node.nodeName.toLowerCase() === type) return node;
|
|
36
|
+
var element = node;
|
|
37
|
+
|
|
38
|
+
while (element.nodeName.toLowerCase() !== type) {
|
|
39
|
+
element = element.parentNode;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return element;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
_this.selectCellsInTable = function (event) {
|
|
46
|
+
if (event.target.nodeName === 'TBODY' || !_this.table.contains(event.target)) {
|
|
47
|
+
// if event.target not in the table, clear the mouseMove event
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_this.endRowIndex = _this.getTableElement(event.target, 'tr').rowIndex;
|
|
52
|
+
_this.endColIndex = _this.getTableElement(event.target, 'td').cellIndex;
|
|
53
|
+
var minRowIndex = Math.min(_this.startRowIndex, _this.endRowIndex),
|
|
54
|
+
maxRowIndex = Math.max(_this.startRowIndex, _this.endRowIndex),
|
|
55
|
+
minColIndex = Math.min(_this.startColIndex, _this.endColIndex),
|
|
56
|
+
maxColIndex = Math.max(_this.startColIndex, _this.endColIndex);
|
|
57
|
+
|
|
58
|
+
if (minRowIndex === maxRowIndex && minColIndex === maxColIndex) {
|
|
59
|
+
return;
|
|
60
|
+
} // collapse selection
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
window.getSelection().collapseToEnd();
|
|
64
|
+
_this.selectedRowRange = {
|
|
65
|
+
min: minRowIndex,
|
|
66
|
+
max: maxRowIndex
|
|
67
|
+
};
|
|
68
|
+
_this.selectedColRange = {
|
|
69
|
+
min: minColIndex,
|
|
70
|
+
max: maxColIndex
|
|
71
|
+
};
|
|
72
|
+
_this.hasSelectedRangeRendered = false;
|
|
73
|
+
|
|
74
|
+
_this.forceUpdate();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
_this.onMouseUp = function () {
|
|
78
|
+
window.document.removeEventListener('mousemove', _this.selectCellsInTable);
|
|
79
|
+
window.document.removeEventListener('mouseup', _this.onMouseUp);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
_this.table = null;
|
|
83
|
+
_this.selectedRowRange = {
|
|
84
|
+
min: -1,
|
|
85
|
+
max: -1
|
|
86
|
+
};
|
|
87
|
+
_this.selectedColRange = {
|
|
88
|
+
min: -1,
|
|
89
|
+
max: -1
|
|
90
|
+
};
|
|
91
|
+
_this.hasSelectedRangeRendered = false;
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
_createClass(TableContainer, [{
|
|
96
|
+
key: "componentDidMount",
|
|
97
|
+
value: function componentDidMount() {
|
|
98
|
+
this.table = ReactDOM.findDOMNode(this);
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "componentDidUpdate",
|
|
102
|
+
value: function componentDidUpdate() {
|
|
103
|
+
var _this$selectedRowRang = this.selectedRowRange,
|
|
104
|
+
minRowIndex = _this$selectedRowRang.min,
|
|
105
|
+
maxRowIndex = _this$selectedRowRang.max;
|
|
106
|
+
var _this$selectedColRang = this.selectedColRange,
|
|
107
|
+
minColIndex = _this$selectedColRang.min,
|
|
108
|
+
maxColIndex = _this$selectedColRang.max;
|
|
109
|
+
|
|
110
|
+
if (minColIndex < 0 || minRowIndex < 0) {
|
|
111
|
+
this.clearSelectedCells();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (this.hasSelectedRangeRendered && this.selectedRowRange.min >= 0 && this.selectedColRange.min >= 0) {
|
|
116
|
+
// if selected range is selected and has rendered reset selected range
|
|
117
|
+
this.selectedColRange = {
|
|
118
|
+
min: -1,
|
|
119
|
+
max: -1
|
|
120
|
+
};
|
|
121
|
+
this.selectedColRange = {
|
|
122
|
+
min: -1,
|
|
123
|
+
max: -1
|
|
124
|
+
};
|
|
125
|
+
return;
|
|
126
|
+
} // clear previous selected style before render
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
this.clearSelectedCells();
|
|
130
|
+
|
|
131
|
+
for (var rowIndex = minRowIndex; rowIndex <= maxRowIndex; rowIndex++) {
|
|
132
|
+
var selectedRow = this.table.querySelectorAll('tr')[rowIndex];
|
|
133
|
+
|
|
134
|
+
for (var colIndex = minColIndex; colIndex <= maxColIndex; colIndex++) {
|
|
135
|
+
selectedRow.querySelectorAll('td')[colIndex].classList.add('selected-cell');
|
|
136
|
+
|
|
137
|
+
if (rowIndex === minRowIndex) {
|
|
138
|
+
selectedRow.querySelectorAll('td')[colIndex].classList.add('selected-cell-top');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (colIndex === minColIndex) {
|
|
142
|
+
selectedRow.querySelectorAll('td')[colIndex].classList.add('selected-cell-left');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (colIndex === maxColIndex) {
|
|
146
|
+
selectedRow.querySelectorAll('td')[colIndex].classList.add('selected-cell-right');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (rowIndex === maxRowIndex) {
|
|
150
|
+
selectedRow.querySelectorAll('td')[colIndex].classList.add('selected-cell-bottom');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
this.hasSelectedRangeRendered = true;
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
key: "render",
|
|
159
|
+
value: function render() {
|
|
160
|
+
var _this$props = this.props,
|
|
161
|
+
attributes = _this$props.attributes,
|
|
162
|
+
children = _this$props.children;
|
|
163
|
+
return /*#__PURE__*/React.createElement("table", {
|
|
164
|
+
onMouseDown: this.selectTable
|
|
165
|
+
}, /*#__PURE__*/React.createElement("tbody", attributes, children));
|
|
166
|
+
}
|
|
167
|
+
}]);
|
|
168
|
+
|
|
169
|
+
return TableContainer;
|
|
170
|
+
}(React.PureComponent);
|
|
171
|
+
|
|
172
|
+
export default TableContainer;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Button } from 'reactstrap';
|
|
7
|
+
import { withTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
var TextLinkHoverMenu = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(TextLinkHoverMenu, _React$Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(TextLinkHoverMenu);
|
|
13
|
+
|
|
14
|
+
function TextLinkHoverMenu(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, TextLinkHoverMenu);
|
|
18
|
+
|
|
19
|
+
_this = _super.call(this, props);
|
|
20
|
+
|
|
21
|
+
_this.saveRef = function (ref) {
|
|
22
|
+
_this.refDom = ref;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
_this.getLinkUrl = function () {
|
|
26
|
+
var linkNode = _this.props.editorUtils.getCurrentLinkNode();
|
|
27
|
+
|
|
28
|
+
if (linkNode) {
|
|
29
|
+
_this.linkUrl = linkNode.data.href;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
_this.setMenuPosition = function () {
|
|
34
|
+
if (window.getSelection().anchorOffset !== 0 && window.getSelection().focusOffset !== 0) {
|
|
35
|
+
var native = window.getSelection();
|
|
36
|
+
var range = native.getRangeAt(0);
|
|
37
|
+
var rect = range.getBoundingClientRect();
|
|
38
|
+
|
|
39
|
+
if (navigator.userAgent.indexOf('Chrome') < 0 && navigator.userAgent.indexOf('Safari') > 0) {
|
|
40
|
+
if (range.collapsed && rect.top === 0 && rect.height === 0) {
|
|
41
|
+
if (range.startOffset === 0) {
|
|
42
|
+
range.setEnd(range.endContainer, 1);
|
|
43
|
+
} else {
|
|
44
|
+
range.setStart(range.startContainer, range.startOffset - 1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
rect = range.getBoundingClientRect();
|
|
48
|
+
|
|
49
|
+
if (rect.top === 0 && rect.height === 0) {
|
|
50
|
+
if (range.getClientRects().length) {
|
|
51
|
+
rect = range.getClientRects()[0];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var style = _this.refDom.style;
|
|
58
|
+
style.zIndex = '1050';
|
|
59
|
+
style.top = "".concat(rect.top - 45, "px");
|
|
60
|
+
var left = parseInt(rect.x - 125);
|
|
61
|
+
|
|
62
|
+
if (left < 0) {
|
|
63
|
+
style.left = '0px';
|
|
64
|
+
} else if (left + 250 > document.body.clientWidth) {
|
|
65
|
+
style.left = "".concat(document.body.clientWidth - 250, "px");
|
|
66
|
+
} else {
|
|
67
|
+
style.left = "".concat(rect.x - 125, "px");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
_this.componentDidMount = function () {
|
|
73
|
+
requestAnimationFrame(function () {
|
|
74
|
+
_this.setMenuPosition();
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
_this.componentWillUnmount = function () {
|
|
79
|
+
_this.refDom = null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
_this.componentWillMount = function () {
|
|
83
|
+
_this.getLinkUrl();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
_this.linkUrl = '';
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
_createClass(TextLinkHoverMenu, [{
|
|
91
|
+
key: "componentDidUpdate",
|
|
92
|
+
value: function componentDidUpdate() {
|
|
93
|
+
this.setMenuPosition();
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "componentWillReceiveProps",
|
|
97
|
+
value: function componentWillReceiveProps() {
|
|
98
|
+
this.getLinkUrl();
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "render",
|
|
102
|
+
value: function render() {
|
|
103
|
+
var _this2 = this;
|
|
104
|
+
|
|
105
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
106
|
+
className: "seafile-ed-hovermenu",
|
|
107
|
+
ref: function ref(_ref) {
|
|
108
|
+
return _this2.refDom = _ref;
|
|
109
|
+
}
|
|
110
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
111
|
+
href: this.linkUrl,
|
|
112
|
+
target: "_blank",
|
|
113
|
+
rel: "noopener noreferrer",
|
|
114
|
+
className: "seafile-ed-hovermenu-link"
|
|
115
|
+
}, this.linkUrl), /*#__PURE__*/React.createElement(Button, {
|
|
116
|
+
color: "",
|
|
117
|
+
className: "seafile-ed-hovermenu-btn",
|
|
118
|
+
onClick: this.props.editorUtils.unwrapLink
|
|
119
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
120
|
+
className: "iconfont icon-delete"
|
|
121
|
+
})), /*#__PURE__*/React.createElement(Button, {
|
|
122
|
+
color: "",
|
|
123
|
+
onClick: this.props.onToggleLinkDialog,
|
|
124
|
+
className: "seafile-ed-hovermenu-btn"
|
|
125
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
126
|
+
className: "iconfont icon-edit"
|
|
127
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
128
|
+
className: "seafile-ed-hovermenu-triangle"
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
}]);
|
|
132
|
+
|
|
133
|
+
return TextLinkHoverMenu;
|
|
134
|
+
}(React.Component);
|
|
135
|
+
|
|
136
|
+
export default withTranslation('seafile-editor')(TextLinkHoverMenu);
|