dumi 2.2.14 → 2.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/features/parser.js
CHANGED
|
@@ -32,16 +32,38 @@ __export(parser_exports, {
|
|
|
32
32
|
default: () => parser_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(parser_exports);
|
|
35
|
+
var import_utils = require("@umijs/utils");
|
|
35
36
|
var import_assert = __toESM(require("assert"));
|
|
36
37
|
var import_meta = require("./meta");
|
|
38
|
+
function filterIgnoredProps(props) {
|
|
39
|
+
return import_utils.lodash.pickBy(props, (prop) => {
|
|
40
|
+
let isHidden = false;
|
|
41
|
+
if (prop.type === "array" && "items" in prop) {
|
|
42
|
+
prop.items = filterIgnoredProps({ _: prop.items })._;
|
|
43
|
+
} else if (prop.type === "object" && "properties" in prop) {
|
|
44
|
+
prop.properties = filterIgnoredProps(prop.properties);
|
|
45
|
+
} else if (prop.oneOf) {
|
|
46
|
+
prop.oneOf = prop.oneOf.map((item) => filterIgnoredProps({ _: item })._);
|
|
47
|
+
} else if (prop.allOf) {
|
|
48
|
+
prop.allOf = prop.allOf.map((item) => filterIgnoredProps({ _: item })._);
|
|
49
|
+
} else if ("hidden" in prop) {
|
|
50
|
+
isHidden = true;
|
|
51
|
+
}
|
|
52
|
+
return !isHidden;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
37
55
|
var parser_default = (api) => {
|
|
38
56
|
let prevData;
|
|
39
57
|
const writeAtomsMetaFile = (data) => {
|
|
58
|
+
const components = import_utils.lodash.mapValues(data.components, (component) => ({
|
|
59
|
+
...component,
|
|
60
|
+
propsConfig: filterIgnoredProps({ _: component.propsConfig })._
|
|
61
|
+
}));
|
|
40
62
|
api.writeTmpFile({
|
|
41
63
|
noPluginDir: true,
|
|
42
64
|
path: import_meta.ATOMS_META_PATH,
|
|
43
65
|
content: `export const components = ${JSON.stringify(
|
|
44
|
-
|
|
66
|
+
components,
|
|
45
67
|
null,
|
|
46
68
|
2
|
|
47
69
|
)};`
|
|
@@ -38,6 +38,7 @@ var import_fs = __toESM(require("fs"));
|
|
|
38
38
|
var import_path = __toESM(require("path"));
|
|
39
39
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
40
40
|
var import_url = __toESM(require("url"));
|
|
41
|
+
var import_remarkContainer = __toESM(require("./remarkContainer"));
|
|
41
42
|
var EMBED_OPEN_TAG = "<embed ";
|
|
42
43
|
var EMBED_CLOSE_TAG = "</embed>";
|
|
43
44
|
var unified;
|
|
@@ -129,7 +130,7 @@ function remarkEmbed(opts) {
|
|
|
129
130
|
const {
|
|
130
131
|
result: mdast,
|
|
131
132
|
data: { embeds }
|
|
132
|
-
} = unified().use(remarkParse).use(remarkEmbed, { ...opts, fileAbsPath: absPath }).use(remarkFrontmatter).use(remarkDirective).use(remarkGfm).use(remarkReplaceSrc, {
|
|
133
|
+
} = unified().use(remarkParse).use(remarkEmbed, { ...opts, fileAbsPath: absPath }).use(remarkFrontmatter).use(remarkDirective).use(import_remarkContainer.default).use(remarkGfm).use(remarkReplaceSrc, {
|
|
133
134
|
fileAbsPath: absPath,
|
|
134
135
|
parentAbsPath: opts.fileAbsPath
|
|
135
136
|
}).use(remarkRawAST).processSync(content);
|
package/package.json
CHANGED
|
@@ -53,7 +53,10 @@ var ColorSwitch = function ColorSwitch() {
|
|
|
53
53
|
onChange: function onChange(ev) {
|
|
54
54
|
return setPrefersColor(ev.target.value);
|
|
55
55
|
},
|
|
56
|
-
value: prefersColor
|
|
56
|
+
value: prefersColor,
|
|
57
|
+
onClick: function onClick(e) {
|
|
58
|
+
return e.stopPropagation();
|
|
59
|
+
}
|
|
57
60
|
}, ['light', 'dark', 'auto'].map(function (c) {
|
|
58
61
|
return /*#__PURE__*/React.createElement("option", {
|
|
59
62
|
value: c,
|
|
@@ -5,7 +5,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
5
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { ReactComponent as IconInbox } from '@ant-design/icons-svg/inline-svg/outlined/inbox.svg';
|
|
8
|
-
import
|
|
8
|
+
import animateScrollTo from 'animated-scroll-to';
|
|
9
|
+
import { FormattedMessage, history, Link, useLocation } from 'dumi';
|
|
9
10
|
import React, { Fragment, useCallback, useEffect, useState } from 'react';
|
|
10
11
|
import "./index.less";
|
|
11
12
|
var IconTitle = function IconTitle() {
|
|
@@ -98,6 +99,20 @@ var SearchResult = function SearchResult(props) {
|
|
|
98
99
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
99
100
|
activeIndex = _useState4[0],
|
|
100
101
|
setActiveIndex = _useState4[1];
|
|
102
|
+
var _useLocation = useLocation(),
|
|
103
|
+
pathname = _useLocation.pathname;
|
|
104
|
+
var onItemSelect = function onItemSelect(item) {
|
|
105
|
+
var _props$onItemSelect;
|
|
106
|
+
(_props$onItemSelect = props.onItemSelect) === null || _props$onItemSelect === void 0 ? void 0 : _props$onItemSelect.call(props, item);
|
|
107
|
+
var url = new URL(item === null || item === void 0 ? void 0 : item.link, location.origin);
|
|
108
|
+
if ((url === null || url === void 0 ? void 0 : url.pathname) === pathname && !url.hash) {
|
|
109
|
+
setTimeout(function () {
|
|
110
|
+
animateScrollTo(0, {
|
|
111
|
+
maxDuration: 300
|
|
112
|
+
});
|
|
113
|
+
}, 1);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
101
116
|
useEffect(function () {
|
|
102
117
|
var handler = function handler(ev) {
|
|
103
118
|
// TODO: scroll into view for invisible items
|
|
@@ -106,12 +121,11 @@ var SearchResult = function SearchResult(props) {
|
|
|
106
121
|
} else if (ev.key === 'ArrowUp') {
|
|
107
122
|
setActiveIndex((activeIndex + histsCount - 1) % histsCount);
|
|
108
123
|
} else if (ev.key === 'Enter' && activeIndex >= 0) {
|
|
109
|
-
var _props$onItemSelect;
|
|
110
124
|
var _item = data.find(function (item) {
|
|
111
125
|
return item.type === 'hint' && item.activeIndex === activeIndex;
|
|
112
126
|
}).value;
|
|
113
127
|
history.push(_item.link);
|
|
114
|
-
|
|
128
|
+
onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(_item);
|
|
115
129
|
document.activeElement.blur();
|
|
116
130
|
}
|
|
117
131
|
if (['Escape', 'Enter'].includes(ev.key)) {
|
|
@@ -145,8 +159,7 @@ var SearchResult = function SearchResult(props) {
|
|
|
145
159
|
to: item.value.link,
|
|
146
160
|
"data-active": activeIndex === item.activeIndex || undefined,
|
|
147
161
|
onClick: function onClick() {
|
|
148
|
-
|
|
149
|
-
return (_props$onItemSelect2 = props.onItemSelect) === null || _props$onItemSelect2 === void 0 ? void 0 : _props$onItemSelect2.call(props, item.value);
|
|
162
|
+
return onItemSelect === null || onItemSelect === void 0 ? void 0 : onItemSelect(item.value);
|
|
150
163
|
}
|
|
151
164
|
}, /*#__PURE__*/React.createElement(ICONS_MAPPING[item.value.type]), /*#__PURE__*/React.createElement("h4", null, /*#__PURE__*/React.createElement(Highlight, {
|
|
152
165
|
texts: item.value.highlightTitleTexts
|