@seafile/sdoc-editor 0.1.76 → 0.1.78
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.
|
@@ -9,21 +9,45 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
|
|
|
9
9
|
return item.nodeName === 'CODE';
|
|
10
10
|
});
|
|
11
11
|
var codeChild = children[0];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
if (codeChild) {
|
|
13
|
+
var lang = codeChild.getAttribute('lang');
|
|
14
|
+
lang = genCodeLangs().find(function (item) {
|
|
15
|
+
return item.value === lang;
|
|
16
|
+
}) || 'plaintext';
|
|
17
|
+
return {
|
|
18
|
+
level: 'level1',
|
|
19
|
+
id: slugid.nice(),
|
|
20
|
+
language: lang,
|
|
21
|
+
type: CODE_BLOCK,
|
|
22
|
+
children: parseChild(children)
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
var _lang = 'plaintext';
|
|
26
|
+
var content = childNodes[0].textContent;
|
|
27
|
+
var _children = content.split('\n').map(function (text) {
|
|
28
|
+
return {
|
|
29
|
+
level: 'level2',
|
|
30
|
+
id: slugid.nice(),
|
|
31
|
+
type: CODE_LINE,
|
|
32
|
+
children: [{
|
|
33
|
+
level: 'level3',
|
|
34
|
+
id: slugid.nice(),
|
|
35
|
+
text: text
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
level: 'level1',
|
|
41
|
+
id: slugid.nice(),
|
|
42
|
+
language: _lang,
|
|
43
|
+
type: CODE_BLOCK,
|
|
44
|
+
children: _children
|
|
45
|
+
};
|
|
46
|
+
}
|
|
23
47
|
}
|
|
24
48
|
if (nodeName === 'CODE' && element.parentElement.nodeName === 'PRE') {
|
|
25
|
-
var
|
|
26
|
-
var hasNewLine =
|
|
49
|
+
var _content = element.textContent;
|
|
50
|
+
var hasNewLine = _content.indexOf('\n') > -1;
|
|
27
51
|
if (!hasNewLine) {
|
|
28
52
|
return {
|
|
29
53
|
level: 'level2',
|
|
@@ -36,7 +60,7 @@ var codeBlockRule = function codeBlockRule(element, parseChild) {
|
|
|
36
60
|
}]
|
|
37
61
|
};
|
|
38
62
|
}
|
|
39
|
-
var codes =
|
|
63
|
+
var codes = _content.split('\n');
|
|
40
64
|
return codes.map(function (item) {
|
|
41
65
|
return {
|
|
42
66
|
level: 'level2',
|
|
@@ -3,22 +3,21 @@ 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 from 'react';
|
|
6
|
-
import { withTranslation } from 'react-i18next';
|
|
7
6
|
import './style.css';
|
|
8
|
-
var
|
|
9
|
-
_inherits(
|
|
10
|
-
var _super = _createSuper(
|
|
11
|
-
function
|
|
7
|
+
var MoreDropdownMenu = /*#__PURE__*/function (_React$Component) {
|
|
8
|
+
_inherits(MoreDropdownMenu, _React$Component);
|
|
9
|
+
var _super = _createSuper(MoreDropdownMenu);
|
|
10
|
+
function MoreDropdownMenu(props) {
|
|
12
11
|
var _this;
|
|
13
|
-
_classCallCheck(this,
|
|
12
|
+
_classCallCheck(this, MoreDropdownMenu);
|
|
14
13
|
_this = _super.call(this, props);
|
|
15
14
|
_this.registerEventHandler = function () {
|
|
16
|
-
document.addEventListener('click', _this.
|
|
15
|
+
document.addEventListener('click', _this.onHideMoreDropdownMenu);
|
|
17
16
|
};
|
|
18
17
|
_this.unregisterEventHandler = function () {
|
|
19
|
-
document.removeEventListener('click', _this.
|
|
18
|
+
document.removeEventListener('click', _this.onHideMoreDropdownMenu);
|
|
20
19
|
};
|
|
21
|
-
_this.
|
|
20
|
+
_this.onHideMoreDropdownMenu = function () {
|
|
22
21
|
_this.setState({
|
|
23
22
|
isDropdownMenuOpen: false
|
|
24
23
|
}, function () {
|
|
@@ -48,7 +47,7 @@ var TextAlignMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
48
47
|
};
|
|
49
48
|
return _this;
|
|
50
49
|
}
|
|
51
|
-
_createClass(
|
|
50
|
+
_createClass(MoreDropdownMenu, [{
|
|
52
51
|
key: "render",
|
|
53
52
|
value: function render() {
|
|
54
53
|
var isDropdownMenuOpen = this.state.isDropdownMenuOpen;
|
|
@@ -64,6 +63,6 @@ var TextAlignMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
64
63
|
}, this.props.children));
|
|
65
64
|
}
|
|
66
65
|
}]);
|
|
67
|
-
return
|
|
66
|
+
return MoreDropdownMenu;
|
|
68
67
|
}(React.Component);
|
|
69
|
-
export default
|
|
68
|
+
export default MoreDropdownMenu;
|
package/package.json
CHANGED