@seafile/seafile-editor 0.3.139 → 0.3.141-1
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.
|
@@ -3,6 +3,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
|
+
import { ReactEditor } from '@seafile/slate-react';
|
|
6
7
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
|
7
8
|
import { withTranslation } from 'react-i18next';
|
|
8
9
|
import EditorBuilder from '../editor/editor-builder';
|
|
@@ -40,7 +41,9 @@ var AddLinkDialog = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
40
41
|
};
|
|
41
42
|
_this.handleSubmit = function (event) {
|
|
42
43
|
event.preventDefault();
|
|
44
|
+
event.stopPropagation();
|
|
43
45
|
if (_this.state.title.length === 0 || _this.state.url.length === 0) return;
|
|
46
|
+
var editor = EditorBuilder.getEditor();
|
|
44
47
|
if (!_this.isLinkActive) {
|
|
45
48
|
_this.editorUtils.insertLink({
|
|
46
49
|
text: _this.state.title,
|
|
@@ -54,6 +57,7 @@ var AddLinkDialog = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
54
57
|
selection: _this.editorSelection
|
|
55
58
|
});
|
|
56
59
|
}
|
|
60
|
+
ReactEditor.focus(editor, _this.editorSelection);
|
|
57
61
|
_this.props.toggleLinkDialog();
|
|
58
62
|
};
|
|
59
63
|
_this.onKeyDown = function (e) {
|
|
@@ -12,23 +12,52 @@ var HeaderList = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
12
12
|
var _this;
|
|
13
13
|
_classCallCheck(this, HeaderList);
|
|
14
14
|
_this = _super.call(this, props);
|
|
15
|
-
_this.
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
if (
|
|
19
|
-
|
|
15
|
+
_this.onHideHeaderMenu = function (e) {
|
|
16
|
+
var menu = _this.menu;
|
|
17
|
+
var clickIsInMenu = menu && menu.contains(e.target) && menu !== e.target;
|
|
18
|
+
if (clickIsInMenu) return;
|
|
19
|
+
_this.setState({
|
|
20
|
+
dropdownOpen: false
|
|
21
|
+
}, function () {
|
|
22
|
+
_this.unregisterEventHandler();
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
_this.registerEventHandler = function () {
|
|
26
|
+
document.addEventListener('mousedown', _this.onHideHeaderMenu, true);
|
|
27
|
+
};
|
|
28
|
+
_this.unregisterEventHandler = function () {
|
|
29
|
+
document.removeEventListener('mousedown', _this.onHideHeaderMenu, true);
|
|
30
|
+
};
|
|
31
|
+
_this.onToggleClick = function (event) {
|
|
32
|
+
event.stopPropagation();
|
|
33
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
34
|
+
var dropdownOpen = !_this.state.dropdownOpen;
|
|
35
|
+
if (dropdownOpen) {
|
|
36
|
+
_this.setState({
|
|
37
|
+
dropdownOpen: dropdownOpen
|
|
38
|
+
}, function () {
|
|
39
|
+
_this.registerEventHandler();
|
|
40
|
+
});
|
|
20
41
|
} else {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
42
|
+
_this.setState({
|
|
43
|
+
dropdownOpen: dropdownOpen
|
|
44
|
+
}, function () {
|
|
45
|
+
_this.unregisterEventHandler();
|
|
46
|
+
});
|
|
26
47
|
}
|
|
27
48
|
};
|
|
28
|
-
_this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
_this.onHeaderClick = function (type) {
|
|
50
|
+
return function (event) {
|
|
51
|
+
_this.props.onClickHeader(event, type);
|
|
52
|
+
_this.setState({
|
|
53
|
+
dropdownOpen: false
|
|
54
|
+
}, function () {
|
|
55
|
+
_this.unregisterEventHandler();
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
_this.setMenuRef = function (ref) {
|
|
60
|
+
_this.menu = ref;
|
|
32
61
|
};
|
|
33
62
|
_this.state = {
|
|
34
63
|
dropdownOpen: false
|
|
@@ -40,72 +69,49 @@ var HeaderList = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
40
69
|
value: function getContainer() {
|
|
41
70
|
return ReactDOM.findDOMNode(this);
|
|
42
71
|
}
|
|
43
|
-
}, {
|
|
44
|
-
key: "componentDidMount",
|
|
45
|
-
value: function componentDidMount() {
|
|
46
|
-
document.addEventListener('click', this.handleClick);
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
key: "componentWillUnmount",
|
|
50
|
-
value: function componentWillUnmount() {
|
|
51
|
-
document.removeEventListener('click', this.handleClick);
|
|
52
|
-
}
|
|
53
72
|
}, {
|
|
54
73
|
key: "render",
|
|
55
74
|
value: function render() {
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
* */
|
|
75
|
+
var disabled = this.props.disabled;
|
|
76
|
+
var dropdownOpen = this.state.dropdownOpen;
|
|
77
|
+
var hoverClass = 'header-list-body-hover';
|
|
78
|
+
var openClass = 'header-list-body-highlight';
|
|
79
|
+
var className = "list-body ".concat(disabled ? '' : hoverClass, " header-list-body-").concat(dropdownOpen ? openClass : '', ")");
|
|
62
80
|
return /*#__PURE__*/React.createElement("div", {
|
|
63
81
|
className: 'header-list'
|
|
64
82
|
}, /*#__PURE__*/React.createElement("div", {
|
|
65
|
-
className:
|
|
83
|
+
className: className,
|
|
84
|
+
onMouseDown: this.onToggleClick
|
|
66
85
|
}, /*#__PURE__*/React.createElement("div", {
|
|
67
86
|
className: 'list-title'
|
|
68
87
|
}, this.props.t(this.props.headerType)), /*#__PURE__*/React.createElement("div", {
|
|
69
88
|
className: 'list-caret'
|
|
70
89
|
}, /*#__PURE__*/React.createElement("i", {
|
|
71
90
|
className: this.state.dropdownOpen ? 'iconfont icon-caret-up' : 'iconfont icon-drop-down'
|
|
72
|
-
}))),
|
|
91
|
+
}))), dropdownOpen && /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
ref: this.setMenuRef,
|
|
73
93
|
className: 'list-dropdown'
|
|
74
94
|
}, /*#__PURE__*/React.createElement("div", {
|
|
75
95
|
className: 'list-dropdown-item',
|
|
76
|
-
onClick:
|
|
77
|
-
_this2.props.onClickHeader(event, 'paragraph');
|
|
78
|
-
}
|
|
96
|
+
onClick: this.onHeaderClick('paragraph')
|
|
79
97
|
}, this.props.t('paragraph')), /*#__PURE__*/React.createElement("div", {
|
|
80
98
|
className: 'list-dropdown-item',
|
|
81
|
-
onClick:
|
|
82
|
-
_this2.props.onClickHeader(event, 'header_one');
|
|
83
|
-
}
|
|
99
|
+
onClick: this.onHeaderClick('header_one')
|
|
84
100
|
}, this.props.t('header_one')), /*#__PURE__*/React.createElement("div", {
|
|
85
101
|
className: 'list-dropdown-item',
|
|
86
|
-
onClick:
|
|
87
|
-
_this2.props.onClickHeader(event, 'header_two');
|
|
88
|
-
}
|
|
102
|
+
onClick: this.onHeaderClick('header_two')
|
|
89
103
|
}, this.props.t('header_two')), /*#__PURE__*/React.createElement("div", {
|
|
90
104
|
className: 'list-dropdown-item',
|
|
91
|
-
onClick:
|
|
92
|
-
_this2.props.onClickHeader(event, 'header_three');
|
|
93
|
-
}
|
|
105
|
+
onClick: this.onHeaderClick('header_three')
|
|
94
106
|
}, this.props.t('header_three')), /*#__PURE__*/React.createElement("div", {
|
|
95
107
|
className: 'list-dropdown-item',
|
|
96
|
-
onClick:
|
|
97
|
-
_this2.props.onClickHeader(event, 'header_four');
|
|
98
|
-
}
|
|
108
|
+
onClick: this.onHeaderClick('header_four')
|
|
99
109
|
}, this.props.t('header_four')), /*#__PURE__*/React.createElement("div", {
|
|
100
110
|
className: 'list-dropdown-item',
|
|
101
|
-
onClick:
|
|
102
|
-
_this2.props.onClickHeader(event, 'header_five');
|
|
103
|
-
}
|
|
111
|
+
onClick: this.onHeaderClick('header_five')
|
|
104
112
|
}, this.props.t('header_five')), /*#__PURE__*/React.createElement("div", {
|
|
105
113
|
className: 'list-dropdown-item',
|
|
106
|
-
onClick:
|
|
107
|
-
_this2.props.onClickHeader(event, 'header_six');
|
|
108
|
-
}
|
|
114
|
+
onClick: this.onHeaderClick('header_six')
|
|
109
115
|
}, this.props.t('header_six'))));
|
|
110
116
|
}
|
|
111
117
|
}]);
|
|
@@ -54,6 +54,11 @@ var EditorBuilder = /*#__PURE__*/function () {
|
|
|
54
54
|
this.slateEditor = withInline(withVoid(withReact(createEditor())));
|
|
55
55
|
return this.slateEditor;
|
|
56
56
|
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "createSlateEditor",
|
|
59
|
+
value: function createSlateEditor(options) {
|
|
60
|
+
return withInline(withVoid(withReact(createEditor())));
|
|
61
|
+
}
|
|
57
62
|
}, {
|
|
58
63
|
key: "resetEditor",
|
|
59
64
|
value: function resetEditor() {
|
|
@@ -29,7 +29,12 @@ var SlateViewer = /*#__PURE__*/function (_React$Component) {
|
|
|
29
29
|
_this.setEditorContainerRef = function (ref) {
|
|
30
30
|
_this.editorContainerRef = ref;
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
var isSeaTable = props.isSeaTable;
|
|
33
|
+
if (isSeaTable) {
|
|
34
|
+
_this.editor = EditorBuilder.createSlateEditor();
|
|
35
|
+
} else {
|
|
36
|
+
_this.editor = EditorBuilder.getSlateEditor();
|
|
37
|
+
}
|
|
33
38
|
window.viewer = _this.editor;
|
|
34
39
|
return _this;
|
|
35
40
|
}
|