ronds-metadata 1.2.10 → 1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- package/es/api/index.js +249 -0
- package/es/comps/DynamicPorts/comps/ContextMenu.js +44 -0
- package/es/comps/DynamicPorts/comps/DragNode.js +55 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +51 -0
- package/es/comps/DynamicPorts/comps/NodeElement.js +30 -0
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +42 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +40 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +55 -0
- package/es/comps/DynamicPorts/comps/shape/connector.js +19 -0
- package/es/comps/DynamicPorts/comps/shape/edge.js +91 -0
- package/es/comps/DynamicPorts/comps/shape/node.js +190 -0
- package/es/comps/DynamicPorts/constant/index.js +19 -0
- package/es/comps/DynamicPorts/graph.js +697 -0
- package/es/comps/DynamicPorts/index.js +143 -0
- package/es/comps/DynamicPorts/interface.js +6 -0
- package/es/comps/DynamicPorts/utils.js +127 -0
- package/es/comps/Editable/DataCell/ButtonCell.js +45 -0
- package/es/comps/Editable/DataCell/ColorPicker.js +33 -0
- package/es/comps/Editable/DataCell/Input.js +54 -0
- package/es/comps/Editable/DataCell/Number.js +44 -0
- package/es/comps/Editable/DataCell/Select.js +48 -0
- package/es/comps/Editable/DataCell/Switch.js +33 -0
- package/es/comps/Editable/comps/EditableAction.js +110 -0
- package/es/comps/Editable/comps/EditableCell.js +108 -0
- package/es/comps/Editable/comps/EditableHeardCell.js +172 -0
- package/es/comps/Editable/comps/EditableRow.js +118 -0
- package/es/comps/Editable/comps/Texty.js +277 -0
- package/es/comps/Editable/index.js +386 -0
- package/es/comps/Editable/interface.js +8 -0
- package/es/comps/Editable/utils.js +46 -0
- package/es/comps/FileView/index.js +198 -0
- package/es/comps/FormGenerator/Provider.js +8 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +69 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +17 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +16 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +17 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +50 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +55 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +14 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +50 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +17 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +69 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +55 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +13 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +50 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +14 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +27 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +261 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +62 -0
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +315 -0
- package/es/comps/FormGenerator/comps/Canvas/index.js +120 -0
- package/es/comps/FormGenerator/comps/Settings/index.js +150 -0
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +48 -0
- package/es/comps/FormGenerator/comps/Sidebar/index.js +37 -0
- package/es/comps/FormGenerator/index.js +68 -0
- package/es/comps/FormGenerator/settings/index.js +367 -0
- package/es/comps/FormGenerator/settings/ruleConfig.js +557 -0
- package/es/comps/FormGenerator/transformer.js +300 -0
- package/es/comps/Icons/index.js +23 -0
- package/es/comps/JsonEdit/constant/index.js +87 -0
- package/es/comps/JsonEdit/index.js +221 -0
- package/es/comps/JsonView/index.js +109 -0
- package/es/comps/MdEdit/index.js +41 -0
- package/es/comps/MdNavbar/index.js +180 -0
- package/es/comps/MdNavbar/utils.js +34 -0
- package/es/comps/MdView/index.js +70 -0
- package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +419 -0
- package/es/comps/MetadataEdit/components/MetaPropsEdit.js +368 -0
- package/es/comps/MetadataEdit/constant/index.js +69 -0
- package/es/comps/MetadataEdit/hooks/index.js +43 -0
- package/es/comps/MetadataEdit/index.js +255 -0
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +237 -0
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +367 -0
- package/es/comps/MetadataEditV2/constant/index.js +69 -0
- package/es/comps/MetadataEditV2/hooks/index.js +43 -0
- package/es/comps/MetadataEditV2/index.js +298 -0
- package/es/comps/MetadataForm/DataCell/Array.js +148 -0
- package/es/comps/MetadataForm/DataCell/Input.js +199 -0
- package/es/comps/MetadataForm/DataCell/Number.js +131 -0
- package/es/comps/MetadataForm/DataCell/Ref.js +326 -0
- package/es/comps/MetadataForm/DataCell/Select.js +558 -0
- package/es/comps/MetadataForm/DataCell/Switch.js +116 -0
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +359 -0
- package/es/comps/MetadataForm/HOC/index.js +126 -0
- package/es/comps/MetadataForm/constants.js +11 -0
- package/es/comps/MetadataForm/hooks/index.js +139 -0
- package/es/comps/MetadataForm/index.js +268 -0
- package/es/comps/MetadataForm/interface.d.ts +2 -1
- package/es/comps/MetadataForm/interface.js +8 -0
- package/es/comps/MetadataForm/utils.js +112 -0
- package/es/comps/locales/en-US.js +24 -0
- package/es/comps/locales/index.js +8 -0
- package/es/comps/locales/zh-CN.js +24 -0
- package/es/config.js +50 -0
- package/es/framework/graph/index.js +515 -0
- package/es/framework/hooks/use-async-memo.js +32 -0
- package/es/framework/hooks/use-sync-scroll.js +106 -0
- package/es/framework/http/cache.js +137 -0
- package/es/framework/http/cancel.js +44 -0
- package/es/framework/http/index.js +392 -0
- package/es/framework/http/msgpack.js +34 -0
- package/es/framework/http/msgpack5/index.js +84 -0
- package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +71 -0
- package/es/framework/http/msgpack5/lib/decoder.js +287 -0
- package/es/framework/http/msgpack5/lib/encoder.js +252 -0
- package/es/framework/http/msgpack5/lib/helpers.js +23 -0
- package/es/framework/http/msgpack5/lib/streams.js +93 -0
- package/es/framework/http/types.js +1 -0
- package/es/framework/libs/jquery.min.js +4022 -0
- package/es/framework/locale/dil8/di18n.js +132 -0
- package/es/framework/locale/dil8/index.js +3 -0
- package/es/framework/locale/dil8/translate.js +76 -0
- package/es/framework/locale/dil8/util.js +17 -0
- package/es/framework/locale/index.js +26 -0
- package/es/framework/metadata/MetadataService.js +169 -0
- package/es/framework/metadata/index.js +384 -0
- package/es/framework/rxjs-hooks/useMemoSubject.js +16 -0
- package/es/framework/rxjs-hooks/useObservable.js +22 -0
- package/es/framework/rxjs-hooks/useObservableState.js +45 -0
- package/es/index.js +27 -0
- package/es/utils.js +138 -0
- package/package.json +1 -1
@@ -0,0 +1,109 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
import React from 'react';
|
3
|
+
import './index.less';
|
4
|
+
|
5
|
+
var JsonView = function JsonView(props) {
|
6
|
+
var json = props.json;
|
7
|
+
|
8
|
+
var _React$useState = React.useState(''),
|
9
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
10
|
+
myJson = _React$useState2[0],
|
11
|
+
setMyJson = _React$useState2[1];
|
12
|
+
|
13
|
+
React.useEffect(function () {
|
14
|
+
try {
|
15
|
+
var textJson = JSON.parse(json);
|
16
|
+
var result = syntaxHighlight(JSON.stringify(textJson, undefined, 2));
|
17
|
+
setMyJson(result);
|
18
|
+
} catch (e) {
|
19
|
+
setMyJson('This is not right JSON');
|
20
|
+
} // eslint-disable-next-line
|
21
|
+
|
22
|
+
}, [json]); // JSON格式转化
|
23
|
+
|
24
|
+
var syntaxHighlight = function syntaxHighlight(_json) {
|
25
|
+
if (typeof json != 'string') {
|
26
|
+
_json = JSON.stringify(json, undefined, 2);
|
27
|
+
}
|
28
|
+
|
29
|
+
var index = 0;
|
30
|
+
_json = _json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
31
|
+
return _json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?|{|}|\[|\])/g, function (match) {
|
32
|
+
var cls = 'number';
|
33
|
+
|
34
|
+
if (/^"/.test(match)) {
|
35
|
+
if (/:$/.test(match)) {
|
36
|
+
cls = 'key';
|
37
|
+
} else {
|
38
|
+
cls = 'string';
|
39
|
+
}
|
40
|
+
} else if (/true|false/.test(match)) {
|
41
|
+
cls = 'boolean';
|
42
|
+
} else if (/null/.test(match)) {
|
43
|
+
cls = 'null';
|
44
|
+
} else if (/{/.test(match)) {
|
45
|
+
index = index + 1;
|
46
|
+
return "<i class=\"open\"></i><span class=\"Object{...}\">".concat(match);
|
47
|
+
} else if (/}/.test(match)) {
|
48
|
+
return "".concat(match, "</span>");
|
49
|
+
} else if (/\[/.test(match)) {
|
50
|
+
return "<i class=\"open\"></i><span class=\"Array\">".concat(match);
|
51
|
+
} else if (/\]/.test(match)) {
|
52
|
+
return "".concat(match, "</span>");
|
53
|
+
}
|
54
|
+
|
55
|
+
return "<span class='".concat(cls, "'>").concat(match, "</span>");
|
56
|
+
});
|
57
|
+
};
|
58
|
+
|
59
|
+
var onClickDom = function onClickDom(e) {
|
60
|
+
var target = e.target;
|
61
|
+
|
62
|
+
if (target.nodeName === 'I') {
|
63
|
+
if (target.className === 'open') {
|
64
|
+
target.className = 'close';
|
65
|
+
var dom = e.target.nextSibling;
|
66
|
+
dom.style.display = 'none';
|
67
|
+
var childNode = document.createElement('em');
|
68
|
+
|
69
|
+
if (dom.className === 'Array') {
|
70
|
+
var childrenList = dom.children;
|
71
|
+
var newList = [];
|
72
|
+
|
73
|
+
for (var i = 0; i < childrenList.length; i++) {
|
74
|
+
if (childrenList[i].nodeName === 'SPAN') {
|
75
|
+
newList.push(childrenList[i]);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
childNode.innerHTML = "".concat(dom.className, "[<em style=\"color:#25aae2;\">").concat(newList.length, "</em>]");
|
80
|
+
} else {
|
81
|
+
childNode.innerHTML = dom.className;
|
82
|
+
}
|
83
|
+
|
84
|
+
e.target.parentNode.insertBefore(childNode, e.target.nextSibling);
|
85
|
+
} else if (target.className === 'close') {
|
86
|
+
e.target.parentNode.removeChild(e.target.nextSibling);
|
87
|
+
target.className = 'open';
|
88
|
+
var _dom = e.target.nextSibling;
|
89
|
+
_dom.style.display = '';
|
90
|
+
}
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
95
|
+
style: {
|
96
|
+
height: '100%',
|
97
|
+
overflow: 'auto'
|
98
|
+
}
|
99
|
+
}, /*#__PURE__*/React.createElement("pre", {
|
100
|
+
onClick: function onClick(e) {
|
101
|
+
onClickDom(e);
|
102
|
+
},
|
103
|
+
dangerouslySetInnerHTML: {
|
104
|
+
__html: myJson
|
105
|
+
}
|
106
|
+
})));
|
107
|
+
};
|
108
|
+
|
109
|
+
export default JsonView;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: your name
|
3
|
+
* @Date: 2021-12-15 15:29:51
|
4
|
+
* @LastEditTime: 2022-09-02 16:52:09
|
5
|
+
*/
|
6
|
+
import React from 'react';
|
7
|
+
import MdEditor from 'react-markdown-editor-lite';
|
8
|
+
import 'react-markdown-editor-lite/lib/index.css';
|
9
|
+
import './index.less';
|
10
|
+
import MdView from '../MdView';
|
11
|
+
|
12
|
+
var MdEdit = function MdEdit(props) {
|
13
|
+
var value = props.value,
|
14
|
+
width = props.width,
|
15
|
+
height = props.height,
|
16
|
+
onChange = props.onChange,
|
17
|
+
onImageUpload = props.onImageUpload,
|
18
|
+
onCustomImageUpload = props.onCustomImageUpload;
|
19
|
+
|
20
|
+
var onValueChange = function onValueChange(v) {
|
21
|
+
onChange && onChange(v.text);
|
22
|
+
};
|
23
|
+
|
24
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MdEditor, {
|
25
|
+
value: value,
|
26
|
+
onImageUpload: onImageUpload,
|
27
|
+
onCustomImageUpload: onCustomImageUpload,
|
28
|
+
style: {
|
29
|
+
width: "".concat(width, "px"),
|
30
|
+
height: "".concat(height, "px")
|
31
|
+
},
|
32
|
+
renderHTML: function renderHTML(text) {
|
33
|
+
return /*#__PURE__*/React.createElement(MdView, {
|
34
|
+
source: text
|
35
|
+
});
|
36
|
+
},
|
37
|
+
onChange: onValueChange
|
38
|
+
}));
|
39
|
+
};
|
40
|
+
|
41
|
+
export default MdEdit;
|
@@ -0,0 +1,180 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
3
|
+
|
4
|
+
/*
|
5
|
+
* @Author: wangxian
|
6
|
+
* @Date: 2022-10-14 09:05:50
|
7
|
+
* @LastEditTime: 2022-10-14 14:25:18
|
8
|
+
*/
|
9
|
+
import React from 'react';
|
10
|
+
import { getCurrentHashValue, trimArrZero } from './utils';
|
11
|
+
import './index.less';
|
12
|
+
|
13
|
+
var MdNavbar = function MdNavbar(props) {
|
14
|
+
var source = props.source,
|
15
|
+
ordered = props.ordered,
|
16
|
+
declarative = props.declarative,
|
17
|
+
className = props.className,
|
18
|
+
onNavItemClick = props.onNavItemClick,
|
19
|
+
onHashChange = props.onHashChange;
|
20
|
+
|
21
|
+
var _React$useState = React.useState([]),
|
22
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
23
|
+
navStructure = _React$useState2[0],
|
24
|
+
setNavStructure = _React$useState2[1];
|
25
|
+
|
26
|
+
var navStructureRef = React.useRef([]);
|
27
|
+
|
28
|
+
var _React$useState3 = React.useState(''),
|
29
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
30
|
+
currentListNo = _React$useState4[0],
|
31
|
+
setCurrentListNo = _React$useState4[1];
|
32
|
+
|
33
|
+
var scrollTimeoutRef = React.useRef();
|
34
|
+
var addTargetTimeoutRef = React.useRef();
|
35
|
+
var getNavStructure = React.useCallback(function () {
|
36
|
+
if (source) {
|
37
|
+
var contentWithoutCode = source.replace(/^[^#]+\n/g, '').replace(/(?:[^\n#]+)#+\s([^#\n]+)\n*/g, '') // 匹配行内出现 # 号的情况
|
38
|
+
.replace(/^#\s[^#\n]*\n+/, '').replace(/```[^`\n]*\n+[^```]+```\n+/g, '').replace(/`([^`\n]+)`/g, '$1').replace(/\*\*?([^*\n]+)\*\*?/g, '$1').replace(/__?([^_\n]+)__?/g, '$1').trim();
|
39
|
+
var pattOfTitle = /#+\s([^#\n]+)\n*/g;
|
40
|
+
var matchResult = contentWithoutCode.match(pattOfTitle);
|
41
|
+
|
42
|
+
if (!matchResult) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
|
46
|
+
var navData = matchResult.map(function (r, i) {
|
47
|
+
return {
|
48
|
+
index: i,
|
49
|
+
level: r.match(/^#+/g)[0].length,
|
50
|
+
text: r.replace(pattOfTitle, '$1')
|
51
|
+
};
|
52
|
+
});
|
53
|
+
var maxLevel = 0;
|
54
|
+
navData.forEach(function (t) {
|
55
|
+
if (t.level > maxLevel) {
|
56
|
+
maxLevel = t.level;
|
57
|
+
}
|
58
|
+
});
|
59
|
+
var matchStack = []; // 此部分重构,原有方法会出现次级标题后再次出现高级标题时,listNo重复的bug
|
60
|
+
|
61
|
+
for (var i = 0; i < navData.length; i++) {
|
62
|
+
var t = navData[i];
|
63
|
+
var level = t.level;
|
64
|
+
|
65
|
+
while (matchStack.length && matchStack[matchStack.length - 1].level > level) {
|
66
|
+
matchStack.pop();
|
67
|
+
}
|
68
|
+
|
69
|
+
if (matchStack.length === 0) {
|
70
|
+
var _arr = new Array(maxLevel).fill(0);
|
71
|
+
|
72
|
+
_arr[level - 1] += 1;
|
73
|
+
matchStack.push({
|
74
|
+
level: level,
|
75
|
+
arr: _arr
|
76
|
+
});
|
77
|
+
t.listNo = trimArrZero(_arr).join('.');
|
78
|
+
continue;
|
79
|
+
}
|
80
|
+
|
81
|
+
var arr = matchStack[matchStack.length - 1].arr;
|
82
|
+
var newArr = arr.slice();
|
83
|
+
newArr[level - 1] += 1;
|
84
|
+
matchStack.push({
|
85
|
+
level: level,
|
86
|
+
arr: newArr
|
87
|
+
});
|
88
|
+
t.listNo = trimArrZero(newArr).join('.');
|
89
|
+
}
|
90
|
+
|
91
|
+
setNavStructure(_toConsumableArray(navData));
|
92
|
+
navStructureRef.current = navData;
|
93
|
+
}
|
94
|
+
}, [source]);
|
95
|
+
var initHeadingsId = React.useCallback(function () {
|
96
|
+
var headingId = decodeURIComponent(declarative ? window.location.hash.replace(/^#/, '').trim() : (window.location.hash.match(/heading-\d+/g) || [])[0]);
|
97
|
+
navStructureRef.current.forEach(function (t) {
|
98
|
+
var headings = document.querySelectorAll("h".concat(t.level));
|
99
|
+
var curHeading = Array.prototype.slice.apply(headings).find(function (h) {
|
100
|
+
return h.innerText.trim() === t.text.trim() && (!h.dataset || !h.dataset.id);
|
101
|
+
});
|
102
|
+
|
103
|
+
if (curHeading) {
|
104
|
+
curHeading.dataset.id = declarative ? "".concat(t.listNo, "-").concat(t.text) : "heading-".concat(t.index);
|
105
|
+
|
106
|
+
if (headingId && headingId === curHeading.dataset.id) {
|
107
|
+
scrollToTarget(headingId);
|
108
|
+
setCurrentListNo(t.listNo);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
});
|
112
|
+
}, []);
|
113
|
+
var refreshNav = React.useCallback(function () {
|
114
|
+
if (addTargetTimeoutRef.current) {
|
115
|
+
clearTimeout(addTargetTimeoutRef.current);
|
116
|
+
}
|
117
|
+
|
118
|
+
addTargetTimeoutRef.current = setTimeout(function () {
|
119
|
+
initHeadingsId();
|
120
|
+
|
121
|
+
if (navStructure.length) {
|
122
|
+
var listNo = navStructure[0].listNo;
|
123
|
+
setCurrentListNo(listNo);
|
124
|
+
}
|
125
|
+
}, 500);
|
126
|
+
}, [navStructure]);
|
127
|
+
React.useEffect(function () {
|
128
|
+
if (source) {
|
129
|
+
getNavStructure();
|
130
|
+
}
|
131
|
+
}, [source, getNavStructure]);
|
132
|
+
React.useEffect(function () {
|
133
|
+
if (source && navStructure && navStructure.length > 0) {
|
134
|
+
refreshNav();
|
135
|
+
}
|
136
|
+
}, [navStructure, source]);
|
137
|
+
|
138
|
+
var scrollToTarget = function scrollToTarget(dataId) {
|
139
|
+
if (scrollTimeoutRef.current) {
|
140
|
+
clearTimeout(scrollTimeoutRef.current);
|
141
|
+
}
|
142
|
+
|
143
|
+
scrollTimeoutRef.current = setTimeout(function () {
|
144
|
+
var target = document.querySelector("[data-id=\"".concat(dataId, "\"]"));
|
145
|
+
|
146
|
+
if (target) {
|
147
|
+
target.scrollIntoView({
|
148
|
+
block: 'start',
|
149
|
+
behavior: 'smooth'
|
150
|
+
});
|
151
|
+
}
|
152
|
+
}, 0);
|
153
|
+
};
|
154
|
+
|
155
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
156
|
+
className: "markdown-navigation ".concat(className)
|
157
|
+
}, navStructure.map(function (t) {
|
158
|
+
var cls = "title-anchor title-level".concat(t.level, " ").concat(currentListNo === t.listNo ? 'active' : '');
|
159
|
+
return /*#__PURE__*/React.createElement("div", {
|
160
|
+
className: cls,
|
161
|
+
onClick: function onClick(evt) {
|
162
|
+
var currentHash = declarative ? "".concat(t.listNo, "-").concat(t.text) // 加入listNo确保hash唯一ZZ
|
163
|
+
: "heading-".concat(t.index); // Avoid execution the callback `onHashChange` when clicking current nav item
|
164
|
+
|
165
|
+
if (t.listNo !== currentListNo) {
|
166
|
+
// Hash changing callback
|
167
|
+
onHashChange && onHashChange(currentHash, getCurrentHashValue());
|
168
|
+
} // Nav item clicking callback
|
169
|
+
|
170
|
+
|
171
|
+
onNavItemClick && onNavItemClick(evt, evt.target, currentHash);
|
172
|
+
scrollToTarget(currentHash);
|
173
|
+
setCurrentListNo(t.listNo);
|
174
|
+
},
|
175
|
+
key: "title_anchor_".concat(Math.random().toString(36).substring(2))
|
176
|
+
}, ordered ? /*#__PURE__*/React.createElement("small", null, t.listNo) : null, t.text);
|
177
|
+
})));
|
178
|
+
};
|
179
|
+
|
180
|
+
export default MdNavbar;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: wangxian
|
3
|
+
* @Date: 2022-10-14 10:03:03
|
4
|
+
* @LastEditTime: 2022-10-14 10:17:18
|
5
|
+
*/
|
6
|
+
export var getCurrentHashValue = function getCurrentHashValue() {
|
7
|
+
return decodeURIComponent(window.location.hash.replace(/^#/, ''));
|
8
|
+
};
|
9
|
+
export var trimArrZero = function trimArrZero(arr) {
|
10
|
+
var start, end;
|
11
|
+
|
12
|
+
for (start = 0; start < arr.length; start++) {
|
13
|
+
if (arr[start]) {
|
14
|
+
break;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
for (end = arr.length - 1; end >= 0; end--) {
|
19
|
+
if (arr[end]) {
|
20
|
+
break;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
return arr.slice(start, end + 1);
|
25
|
+
};
|
26
|
+
export var updateHash = function updateHash(updateHashTimeout, value) {
|
27
|
+
if (updateHashTimeout) {
|
28
|
+
clearTimeout(updateHashTimeout);
|
29
|
+
}
|
30
|
+
|
31
|
+
updateHashTimeout = setTimeout(function () {
|
32
|
+
window.history.replaceState({}, '', "".concat(window.location.pathname).concat(window.location.search, "#").concat(value));
|
33
|
+
}, 0);
|
34
|
+
};
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["node", "inline", "className", "children"];
|
4
|
+
import React from "react";
|
5
|
+
|
6
|
+
/*
|
7
|
+
* @Author: wangxian
|
8
|
+
* @Date: 2022-09-02 16:17:38
|
9
|
+
* @LastEditTime: 2022-11-23 09:09:46
|
10
|
+
*/
|
11
|
+
import ReactMarkdown from 'react-markdown';
|
12
|
+
import remarkGfm from 'remark-gfm';
|
13
|
+
import rehypeRaw from 'rehype-raw';
|
14
|
+
import 'github-markdown-css';
|
15
|
+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
16
|
+
import { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
17
|
+
import './index.less';
|
18
|
+
import MdNavbar from '../MdNavbar';
|
19
|
+
|
20
|
+
var MdView = function MdView(props) {
|
21
|
+
var source = props.source,
|
22
|
+
_props$isMarkNav = props.isMarkNav,
|
23
|
+
isMarkNav = _props$isMarkNav === void 0 ? false : _props$isMarkNav,
|
24
|
+
navOptions = props.navOptions;
|
25
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
26
|
+
className: "react-mark-down",
|
27
|
+
style: {
|
28
|
+
height: '100%',
|
29
|
+
display: 'flex'
|
30
|
+
}
|
31
|
+
}, /*#__PURE__*/React.createElement("div", {
|
32
|
+
className: "markdown-body react-mark-down"
|
33
|
+
}, /*#__PURE__*/React.createElement(ReactMarkdown, {
|
34
|
+
remarkPlugins: [remarkGfm],
|
35
|
+
rehypePlugins: [rehypeRaw],
|
36
|
+
components: {
|
37
|
+
code: function code(_ref) {
|
38
|
+
var node = _ref.node,
|
39
|
+
inline = _ref.inline,
|
40
|
+
className = _ref.className,
|
41
|
+
children = _ref.children,
|
42
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
43
|
+
|
44
|
+
var match = /language-(\w+)/.exec(className || 'javascript');
|
45
|
+
return !inline && match ? /*#__PURE__*/React.createElement(SyntaxHighlighter, _extends({
|
46
|
+
showLineNumbers: true,
|
47
|
+
style: oneLight,
|
48
|
+
language: match[1],
|
49
|
+
PreTag: "div",
|
50
|
+
className: "self-highlighter"
|
51
|
+
}, props), String(children).replace(/\n$/, '')) : /*#__PURE__*/React.createElement("code", _extends({
|
52
|
+
className: className
|
53
|
+
}, props), children);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}, source)), isMarkNav && /*#__PURE__*/React.createElement("div", {
|
57
|
+
style: {
|
58
|
+
width: '250px',
|
59
|
+
height: '100%',
|
60
|
+
padding: '10px',
|
61
|
+
overflowY: 'auto'
|
62
|
+
}
|
63
|
+
}, /*#__PURE__*/React.createElement(MdNavbar, _extends({
|
64
|
+
className: "h-full w-full",
|
65
|
+
source: source,
|
66
|
+
ordered: true
|
67
|
+
}, navOptions)))));
|
68
|
+
};
|
69
|
+
|
70
|
+
export default MdView;
|