@antv/dumi-theme-antv 0.3.8 → 0.3.10
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/pages/Example/index.js +7 -7
- package/dist/plugin/index.js +13 -9
- package/dist/slots/CodeEditor/Toolbar.d.ts +1 -0
- package/dist/slots/CodeEditor/Toolbar.js +6 -5
- package/dist/slots/CodeEditor/index.js +212 -54
- package/dist/slots/CodeEditor/utils.d.ts +1 -1
- package/dist/slots/CodeEditor/utils.js +2 -1
- package/dist/slots/Header/Search/SearchResult.d.ts +21 -0
- package/dist/slots/Header/Search/SearchResult.js +35 -0
- package/dist/slots/Header/Search/SearchResult.module.less +65 -0
- package/dist/slots/Header/Search/helper.d.ts +8 -0
- package/dist/slots/Header/Search/helper.js +25 -0
- package/dist/slots/Header/Search/index.d.ts +2 -0
- package/dist/slots/Header/Search/index.js +59 -0
- package/dist/slots/Header/{Search.module.less → Search/index.module.less} +1 -9
- package/dist/slots/ManualContent/Preview.d.ts +7 -0
- package/dist/slots/ManualContent/Preview.js +204 -0
- package/dist/slots/ManualContent/Preview.module.less +62 -0
- package/dist/slots/ManualContent/index.js +11 -9
- package/dist/slots/ManualContent/usePreview.d.ts +1 -0
- package/dist/slots/ManualContent/usePreview.js +89 -0
- package/dist/slots/utils.js +16 -5
- package/package.json +4 -3
- package/dist/plugin/utils.d.ts +0 -5
- package/dist/plugin/utils.js +0 -53
- package/dist/slots/Header/Search.d.ts +0 -12
- package/dist/slots/Header/Search.js +0 -87
|
@@ -4,17 +4,17 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
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
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
8
|
-
import { useParams, useLocation, useNavigate } from 'react-router-dom';
|
|
9
|
-
import { get } from 'lodash-es';
|
|
10
7
|
import { Layout } from 'antd';
|
|
11
8
|
import { useLocale, useSiteData } from 'dumi';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import { get } from 'lodash-es';
|
|
10
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
11
|
+
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
12
|
+
import { ThemeAntVContext } from "../../context";
|
|
15
13
|
import { CodeRunner } from "dumi/theme/slots/CodeRunner";
|
|
16
14
|
import { getDemoInfo } from "../../slots/CodeRunner/utils";
|
|
17
|
-
import {
|
|
15
|
+
import { ExampleSider } from "dumi/theme/slots/ExampleSider";
|
|
16
|
+
import { Header } from "dumi/theme/slots/Header";
|
|
17
|
+
import { SEO } from "dumi/theme/slots/SEO";
|
|
18
18
|
import styles from "./index.module.less";
|
|
19
19
|
import { getCurrentTitle } from "./utils";
|
|
20
20
|
var Sider = Layout.Sider,
|
package/dist/plugin/index.js
CHANGED
|
@@ -33,8 +33,10 @@ __export(plugin_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(plugin_exports);
|
|
35
35
|
var path = __toESM(require("path"));
|
|
36
|
+
var import_plugin_utils = require("dumi/plugin-utils");
|
|
36
37
|
var import_examples = require("./examples");
|
|
37
|
-
var
|
|
38
|
+
var ALIAS_PAGES_KEY = "@/antv__theme__pages";
|
|
39
|
+
var MOCK_META = { frontmatter: { title: "mock-meta" }, texts: [], toc: [] };
|
|
38
40
|
var plugin_default = (api) => {
|
|
39
41
|
api.describe({ key: `dumi-theme:${require("../../package.json").name}` });
|
|
40
42
|
api.modifyDefaultConfig((memo) => {
|
|
@@ -43,6 +45,7 @@ var plugin_default = (api) => {
|
|
|
43
45
|
memo.mfsu = false;
|
|
44
46
|
memo.jsMinifier = "terser";
|
|
45
47
|
memo.favicons = ["https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7svFR6wkPMoAAAAAAAAAAAAADmJ7AQ/original"];
|
|
48
|
+
memo.alias[ALIAS_PAGES_KEY] = path.join(__dirname, "../pages");
|
|
46
49
|
return memo;
|
|
47
50
|
});
|
|
48
51
|
const pages = [
|
|
@@ -62,26 +65,25 @@ var plugin_default = (api) => {
|
|
|
62
65
|
{
|
|
63
66
|
id: "dumi-theme-antv-example-list-zh",
|
|
64
67
|
absPath: "/examples",
|
|
65
|
-
file:
|
|
68
|
+
file: `${ALIAS_PAGES_KEY}/Examples`
|
|
66
69
|
},
|
|
67
70
|
{
|
|
68
71
|
id: "dumi-theme-antv-example-list-lang",
|
|
69
72
|
absPath: "/:language/examples",
|
|
70
|
-
file:
|
|
73
|
+
file: `${ALIAS_PAGES_KEY}/Examples`
|
|
71
74
|
},
|
|
72
75
|
// single example preview page.
|
|
73
76
|
{
|
|
74
77
|
id: "dumi-theme-antv-single-example-zh",
|
|
75
78
|
absPath: "/examples/:topic/:example",
|
|
76
|
-
file:
|
|
79
|
+
file: `${ALIAS_PAGES_KEY}/Example`
|
|
77
80
|
},
|
|
78
81
|
{
|
|
79
82
|
id: "dumi-theme-antv-single-example-lang",
|
|
80
83
|
absPath: "/:language/examples/:topic/:example",
|
|
81
|
-
file:
|
|
84
|
+
file: `${ALIAS_PAGES_KEY}/Example`
|
|
82
85
|
}
|
|
83
86
|
];
|
|
84
|
-
const contextFilePath = (0, import_utils.myResolve)("../context.ts");
|
|
85
87
|
api.onGenerateFiles(() => {
|
|
86
88
|
api.writeTmpFile({
|
|
87
89
|
noPluginDir: true,
|
|
@@ -89,7 +91,7 @@ var plugin_default = (api) => {
|
|
|
89
91
|
content: `
|
|
90
92
|
import React from 'react';
|
|
91
93
|
import { useOutlet, useSiteData } from 'dumi';
|
|
92
|
-
import { ThemeAntVContext } from '${
|
|
94
|
+
import { ThemeAntVContext } from '${(0, import_plugin_utils.winPath)(path.join(__dirname, "../context"))}';
|
|
93
95
|
|
|
94
96
|
export default function ThemeAntVContextWrapper() {
|
|
95
97
|
const outlet = useOutlet();
|
|
@@ -120,10 +122,12 @@ export default function ThemeAntVContextWrapper() {
|
|
|
120
122
|
path: page.absPath.slice(1),
|
|
121
123
|
absPath: page.absPath,
|
|
122
124
|
file: page.file,
|
|
123
|
-
parentId: "DocLayout"
|
|
125
|
+
parentId: "DocLayout",
|
|
126
|
+
meta: MOCK_META
|
|
124
127
|
};
|
|
125
128
|
});
|
|
126
|
-
routes["404"].file =
|
|
129
|
+
routes["404"].file = `${ALIAS_PAGES_KEY}/404`;
|
|
130
|
+
routes["404"].meta = MOCK_META;
|
|
127
131
|
return routes;
|
|
128
132
|
});
|
|
129
133
|
api.addTmpGenerateWatcherPaths(() => [path.resolve(process.cwd(), "examples")]);
|
|
@@ -10,19 +10,20 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
10
10
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
11
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
12
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
13
|
-
import React, { useEffect, useState } from 'react';
|
|
14
13
|
import { CodeSandboxOutlined, PlayCircleOutlined, ThunderboltOutlined } from '@ant-design/icons';
|
|
15
|
-
import { Typography, Tooltip } from 'antd';
|
|
16
|
-
import { useLocale, FormattedMessage } from 'dumi';
|
|
17
|
-
import { getParameters } from 'codesandbox/lib/api/define';
|
|
18
14
|
import stackblitzSdk from '@stackblitz/sdk';
|
|
15
|
+
import { Tooltip, Typography } from 'antd';
|
|
16
|
+
import { getParameters } from 'codesandbox/lib/api/define';
|
|
17
|
+
import { FormattedMessage, useLocale } from 'dumi';
|
|
18
|
+
import React, { useEffect, useState } from 'react';
|
|
19
19
|
import { ping } from "../utils";
|
|
20
|
-
import { extractImportDeps, getCodeSandboxConfig,
|
|
20
|
+
import { extractImportDeps, getCodeSandboxConfig, getRiddleConfig, getStackblitzConfig } from "./utils";
|
|
21
21
|
import styles from "./Toolbar.module.less";
|
|
22
22
|
var Paragraph = Typography.Paragraph;
|
|
23
23
|
export var EDITOR_TABS;
|
|
24
24
|
(function (EDITOR_TABS) {
|
|
25
25
|
EDITOR_TABS["JAVASCRIPT"] = "JavaScript";
|
|
26
|
+
EDITOR_TABS["SPEC"] = "Spec";
|
|
26
27
|
EDITOR_TABS["DATA"] = "Data";
|
|
27
28
|
})(EDITOR_TABS || (EDITOR_TABS = {}));
|
|
28
29
|
export var Toolbar = function Toolbar(_ref) {
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
2
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
13
|
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
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import React, { useRef, useState, useCallback, useEffect } from 'react';
|
|
8
15
|
import MonacoEditor, { loader } from '@monaco-editor/react';
|
|
9
|
-
import {
|
|
16
|
+
import { autoType as d3AutoType, dsvFormat } from 'd3-dsv';
|
|
17
|
+
import { useLocale, useSiteData } from 'dumi';
|
|
10
18
|
import { debounce, noop } from 'lodash-es';
|
|
19
|
+
import { format } from 'prettier';
|
|
20
|
+
import parserBabel from 'prettier/parser-babel';
|
|
21
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
22
|
import { bind, clear } from 'size-sensor';
|
|
12
|
-
import { replaceInsertCss, execute, compile } from "./utils";
|
|
13
|
-
import { Toolbar, EDITOR_TABS } from "./Toolbar";
|
|
14
23
|
import { Loading } from "dumi/theme/slots/Loading";
|
|
24
|
+
import { EDITOR_TABS, Toolbar } from "./Toolbar";
|
|
15
25
|
import styles from "./index.module.less";
|
|
26
|
+
import { compile, execute, replaceInsertCss } from "./utils";
|
|
16
27
|
loader.config({
|
|
17
28
|
'vs/nls': {
|
|
18
29
|
availableLanguages: {
|
|
@@ -46,31 +57,41 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
46
57
|
_ref$onFullscreen = _ref.onFullscreen,
|
|
47
58
|
onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen;
|
|
48
59
|
var locale = useLocale();
|
|
49
|
-
var _useSiteData
|
|
50
|
-
|
|
60
|
+
var _useSiteData = useSiteData(),
|
|
61
|
+
themeConfig = _useSiteData.themeConfig;
|
|
62
|
+
var _themeConfig$es = themeConfig.es5,
|
|
63
|
+
es5 = _themeConfig$es === void 0 ? true : _themeConfig$es,
|
|
64
|
+
_themeConfig$showSpec = themeConfig.showSpecTab,
|
|
65
|
+
showSpecTab = _themeConfig$showSpec === void 0 ? false : _themeConfig$showSpec;
|
|
66
|
+
var _themeConfig$playgrou = themeConfig.playground.extraLib,
|
|
67
|
+
extraLib = _themeConfig$playgrou === void 0 ? '' : _themeConfig$playgrou;
|
|
51
68
|
// 编辑器两个 tab,分别是代码和数据
|
|
52
69
|
var _useState = useState(null),
|
|
53
70
|
_useState2 = _slicedToArray(_useState, 2),
|
|
54
71
|
data = _useState2[0],
|
|
55
72
|
setData = _useState2[1];
|
|
56
|
-
var _useState3 = useState(
|
|
73
|
+
var _useState3 = useState(null),
|
|
57
74
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
-
|
|
59
|
-
|
|
75
|
+
spec = _useState4[0],
|
|
76
|
+
setSpec = _useState4[1];
|
|
77
|
+
var _useState5 = useState(source),
|
|
78
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
79
|
+
code = _useState6[0],
|
|
80
|
+
setCode = _useState6[1];
|
|
60
81
|
// monaco instance
|
|
61
82
|
var monacoRef = useRef(null);
|
|
62
83
|
// 文件后缀
|
|
63
84
|
var fileExtension = relativePath.split('.')[relativePath.split('.').length - 1] || 'js';
|
|
64
85
|
// 菜单栏
|
|
65
|
-
var
|
|
66
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
67
|
-
editorTabs = _useState6[0],
|
|
68
|
-
setEditorTabs = _useState6[1];
|
|
69
|
-
// 当前选中菜单栏
|
|
70
|
-
var _useState7 = useState(EDITOR_TABS.JAVASCRIPT),
|
|
86
|
+
var _useState7 = useState([]),
|
|
71
87
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
72
|
-
|
|
73
|
-
|
|
88
|
+
editorTabs = _useState8[0],
|
|
89
|
+
setEditorTabs = _useState8[1];
|
|
90
|
+
// 当前选中菜单栏
|
|
91
|
+
var _useState9 = useState(EDITOR_TABS.JAVASCRIPT),
|
|
92
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
93
|
+
currentEditorTab = _useState10[0],
|
|
94
|
+
setCurrentEditorTab = _useState10[1];
|
|
74
95
|
var containerId = "playgroundScriptContainer_".concat(exampleId);
|
|
75
96
|
|
|
76
97
|
// 出发 auto resize
|
|
@@ -112,7 +133,7 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
112
133
|
// 1. 先编译代码
|
|
113
134
|
var compiled;
|
|
114
135
|
try {
|
|
115
|
-
compiled = compile(replaceInsertCss(v, locale.id), relativePath);
|
|
136
|
+
compiled = compile(replaceInsertCss(v, locale.id), relativePath, es5);
|
|
116
137
|
} catch (e) {
|
|
117
138
|
reportError(e);
|
|
118
139
|
// 执行出错,后面的步骤不用做了!
|
|
@@ -122,8 +143,32 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
122
143
|
// 2. 执行代码,try catch 在内部已经做了
|
|
123
144
|
execute(compiled, containerId, playground === null || playground === void 0 ? void 0 : playground.container, replaceId);
|
|
124
145
|
}, 300), [exampleId, currentEditorTab]);
|
|
146
|
+
var updateData = function updateData(data) {
|
|
147
|
+
if (!data) return;
|
|
148
|
+
var tabs = showSpecTab ? [EDITOR_TABS.JAVASCRIPT, EDITOR_TABS.SPEC, EDITOR_TABS.DATA] : [EDITOR_TABS.JAVASCRIPT, EDITOR_TABS.DATA];
|
|
149
|
+
setEditorTabs(tabs);
|
|
150
|
+
setData(data);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// 找到 spec 里面的 online data 并且更新它
|
|
154
|
+
var updateDataFromSpec = function updateDataFromSpec(options) {
|
|
155
|
+
if (!options) return;
|
|
156
|
+
var discoverd = [options];
|
|
157
|
+
var dataList = [];
|
|
158
|
+
while (discoverd.length) {
|
|
159
|
+
var node = discoverd.pop();
|
|
160
|
+
var _data = node.data;
|
|
161
|
+
if (_typeof(_data) === 'object' && _data.type === 'fetch') {
|
|
162
|
+
dataList.push(_data);
|
|
163
|
+
}
|
|
164
|
+
discoverd.push.apply(discoverd, _toConsumableArray(node.children || []));
|
|
165
|
+
}
|
|
166
|
+
fetchData(dataList.map(function (d) {
|
|
167
|
+
return d.value;
|
|
168
|
+
})).then(updateData);
|
|
169
|
+
};
|
|
125
170
|
|
|
126
|
-
//
|
|
171
|
+
// 案例变化的时候,修改代码
|
|
127
172
|
useEffect(function () {
|
|
128
173
|
setCode(source);
|
|
129
174
|
}, [exampleId]);
|
|
@@ -158,21 +203,85 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
158
203
|
};
|
|
159
204
|
}, []);
|
|
160
205
|
|
|
206
|
+
// fetch 多份远程数据,如果有多份合并成一份。
|
|
207
|
+
var fetchData = /*#__PURE__*/function () {
|
|
208
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(urls) {
|
|
209
|
+
var parseCSV, parseJSON, dataList;
|
|
210
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
211
|
+
while (1) switch (_context.prev = _context.next) {
|
|
212
|
+
case 0:
|
|
213
|
+
parseCSV = function parseCSV(response) {
|
|
214
|
+
return response.text().then(function (text) {
|
|
215
|
+
return dsvFormat(',').parse(text, d3AutoType);
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
parseJSON = function parseJSON(response) {
|
|
219
|
+
return response.json();
|
|
220
|
+
};
|
|
221
|
+
_context.next = 4;
|
|
222
|
+
return Promise.all(urls.map(function (url) {
|
|
223
|
+
return fetch(url).then(function (response) {
|
|
224
|
+
var format = url.split('.').pop();
|
|
225
|
+
if (format === 'csv') return parseCSV(response);
|
|
226
|
+
return parseJSON(response);
|
|
227
|
+
});
|
|
228
|
+
}));
|
|
229
|
+
case 4:
|
|
230
|
+
dataList = _context.sent;
|
|
231
|
+
if (!(dataList.length <= 1)) {
|
|
232
|
+
_context.next = 7;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
return _context.abrupt("return", dataList[0]);
|
|
236
|
+
case 7:
|
|
237
|
+
return _context.abrupt("return", Object.fromEntries(urls.map(function (url, index) {
|
|
238
|
+
return [url, dataList[index]];
|
|
239
|
+
})));
|
|
240
|
+
case 8:
|
|
241
|
+
case "end":
|
|
242
|
+
return _context.stop();
|
|
243
|
+
}
|
|
244
|
+
}, _callee);
|
|
245
|
+
}));
|
|
246
|
+
return function fetchData(_x2) {
|
|
247
|
+
return _ref2.apply(this, arguments);
|
|
248
|
+
};
|
|
249
|
+
}();
|
|
250
|
+
|
|
251
|
+
// 切换 example 的时候,切换到代码编辑页面
|
|
252
|
+
// 用于更新当前 example 的 spec 和 data
|
|
253
|
+
useEffect(function () {
|
|
254
|
+
setCurrentEditorTab(EDITOR_TABS.JAVASCRIPT);
|
|
255
|
+
}, [exampleId]);
|
|
256
|
+
|
|
161
257
|
// hook 用户的数据
|
|
162
258
|
useEffect(function () {
|
|
163
|
-
|
|
259
|
+
// 需要匹配首位的换行符,以及 ' 和 "
|
|
260
|
+
var dataFileMatch = source.match(/fetch\(\s*["|'](.*)["|']\s*\)/);
|
|
164
261
|
if (dataFileMatch && dataFileMatch.length > 0) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}).then(function (data) {
|
|
168
|
-
setEditorTabs([EDITOR_TABS.JAVASCRIPT, EDITOR_TABS.DATA]);
|
|
169
|
-
setData(data);
|
|
262
|
+
fetchData([dataFileMatch[1].trim()]).then(function (data) {
|
|
263
|
+
updateData(data);
|
|
170
264
|
});
|
|
171
265
|
} else {
|
|
172
|
-
|
|
266
|
+
var tabs = showSpecTab ? [EDITOR_TABS.JAVASCRIPT, EDITOR_TABS.SPEC] : [EDITOR_TABS.JAVASCRIPT];
|
|
267
|
+
setEditorTabs(tabs);
|
|
173
268
|
}
|
|
174
269
|
}, [exampleId]);
|
|
175
270
|
|
|
271
|
+
// 监听更新 spec 的事件,这是一个定义事件,需要在 .dumi/global.ts 里面 dispatch
|
|
272
|
+
useEffect(function () {
|
|
273
|
+
var update = function update(e) {
|
|
274
|
+
var _ref3 = e.detail,
|
|
275
|
+
options = _ref3.options;
|
|
276
|
+
setSpec(options);
|
|
277
|
+
updateDataFromSpec(options);
|
|
278
|
+
};
|
|
279
|
+
window.addEventListener('spec', update);
|
|
280
|
+
return function () {
|
|
281
|
+
window.removeEventListener('spec', update);
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
|
|
176
285
|
// 切换 tab
|
|
177
286
|
var onTabChange = useCallback(function (tab) {
|
|
178
287
|
setCurrentEditorTab(tab);
|
|
@@ -190,6 +299,52 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
190
299
|
setCode(value);
|
|
191
300
|
}
|
|
192
301
|
}, [currentEditorTab]);
|
|
302
|
+
var parseFunction = function parseFunction(string) {
|
|
303
|
+
return string.replace(/"\<func\>(.*)\<\/func\>"/g, function (_, code) {
|
|
304
|
+
return code;
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// 序列化 JavaScript 对象的时候对 function 进行特殊的标注,
|
|
309
|
+
// 使得解析该字符串的时候能方便的提取 function 对应的字符串。
|
|
310
|
+
// { add: (x, y) => x + y } => '{ add: <func>(x, y) => x + y</func> }'
|
|
311
|
+
var withFunction = function withFunction(_, value) {
|
|
312
|
+
if (typeof value !== 'function') return value;
|
|
313
|
+
return "<func>".concat(value.toString().replace(/\n/g, ''), "</func>");
|
|
314
|
+
};
|
|
315
|
+
var languageOf = function languageOf(tab) {
|
|
316
|
+
switch (tab) {
|
|
317
|
+
case EDITOR_TABS.JAVASCRIPT:
|
|
318
|
+
case EDITOR_TABS.SPEC:
|
|
319
|
+
return 'javascript';
|
|
320
|
+
case EDITOR_TABS.DATA:
|
|
321
|
+
return 'json';
|
|
322
|
+
default:
|
|
323
|
+
return 'javascript';
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
var valueOf = function valueOf(tab) {
|
|
327
|
+
switch (tab) {
|
|
328
|
+
case EDITOR_TABS.JAVASCRIPT:
|
|
329
|
+
return code;
|
|
330
|
+
case EDITOR_TABS.SPEC:
|
|
331
|
+
return format(parseFunction("(".concat(JSON.stringify(spec, withFunction), ")")), {
|
|
332
|
+
plugins: [parserBabel]
|
|
333
|
+
});
|
|
334
|
+
case EDITOR_TABS.DATA:
|
|
335
|
+
return JSON.stringify(data, null, 2);
|
|
336
|
+
default:
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
var defaultOf = function defaultOf(tab) {
|
|
341
|
+
switch (tab) {
|
|
342
|
+
case EDITOR_TABS.JAVASCRIPT:
|
|
343
|
+
return code;
|
|
344
|
+
default:
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
193
348
|
return /*#__PURE__*/React.createElement("div", {
|
|
194
349
|
className: styles.editor
|
|
195
350
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
@@ -206,33 +361,36 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
206
361
|
},
|
|
207
362
|
onEditorTabChange: onTabChange,
|
|
208
363
|
onToggleFullscreen: onFullscreen
|
|
209
|
-
}),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
364
|
+
}), editorTabs.map(function (tab) {
|
|
365
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
366
|
+
key: tab,
|
|
367
|
+
className: styles.monaco,
|
|
368
|
+
style: {
|
|
369
|
+
height: 'calc(100% - 36px)',
|
|
370
|
+
display: tab === currentEditorTab ? 'block' : 'none'
|
|
371
|
+
}
|
|
372
|
+
}, /*#__PURE__*/React.createElement(MonacoEditor, {
|
|
373
|
+
language: languageOf(tab),
|
|
374
|
+
value: valueOf(tab),
|
|
375
|
+
defaultValue: defaultOf(tab),
|
|
376
|
+
path: tab,
|
|
377
|
+
loading: /*#__PURE__*/React.createElement(Loading, null),
|
|
378
|
+
options: {
|
|
379
|
+
readOnly: tab === EDITOR_TABS.DATA || tab === EDITOR_TABS.SPEC,
|
|
380
|
+
automaticLayout: true,
|
|
381
|
+
minimap: {
|
|
382
|
+
enabled: false
|
|
383
|
+
},
|
|
384
|
+
scrollBeyondLastLine: false,
|
|
385
|
+
fixedOverflowWidgets: true,
|
|
386
|
+
lineNumbersMinChars: 4,
|
|
387
|
+
showFoldingControls: 'always',
|
|
388
|
+
foldingHighlight: true
|
|
226
389
|
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
onChange: onCodeChange,
|
|
234
|
-
onMount: function onMount(editor) {
|
|
235
|
-
monacoRef.current = editor;
|
|
236
|
-
}
|
|
237
|
-
})));
|
|
390
|
+
onChange: onCodeChange,
|
|
391
|
+
onMount: function onMount(editor) {
|
|
392
|
+
monacoRef.current = editor;
|
|
393
|
+
}
|
|
394
|
+
}));
|
|
395
|
+
}));
|
|
238
396
|
};
|
|
@@ -39,4 +39,4 @@ export declare function execute(code: string, playgroundScriptContainer: string,
|
|
|
39
39
|
/**
|
|
40
40
|
* 编译代码
|
|
41
41
|
*/
|
|
42
|
-
export declare function compile(value: string, relativePath: string): any;
|
|
42
|
+
export declare function compile(value: string, relativePath: string, es5?: boolean): any;
|
|
@@ -130,9 +130,10 @@ export function execute(code, playgroundScriptContainer, container) {
|
|
|
130
130
|
* 编译代码
|
|
131
131
|
*/
|
|
132
132
|
export function compile(value, relativePath) {
|
|
133
|
+
var es5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
133
134
|
var _transform = transform(value, {
|
|
134
135
|
filename: relativePath,
|
|
135
|
-
presets: ['react', 'typescript', 'es2015', ['stage-3', {
|
|
136
|
+
presets: ['react', 'typescript', es5 ? 'es2015' : 'es2016', ['stage-3', {
|
|
136
137
|
decoratorsBeforeExport: true
|
|
137
138
|
}]],
|
|
138
139
|
plugins: ['transform-modules-umd']
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type ITextSegment = {
|
|
3
|
+
text: string;
|
|
4
|
+
highlighted?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare type ISearchResult = {
|
|
7
|
+
/**
|
|
8
|
+
* 搜索结果的主题,显示在最左边,一般是页面的标题。
|
|
9
|
+
*/
|
|
10
|
+
subject: string;
|
|
11
|
+
tilte: ITextSegment[];
|
|
12
|
+
description?: ITextSegment[];
|
|
13
|
+
link: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 展示搜索结果
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare const SearchResult: React.FC<{
|
|
20
|
+
results: ISearchResult[];
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from "./SearchResult.module.less";
|
|
3
|
+
var getHighlightInfo = function getHighlightInfo(textSegments) {
|
|
4
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, textSegments.map(function (segment) {
|
|
5
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
6
|
+
className: "".concat(styles.segment, " ").concat(segment.highlighted ? styles.highlighted : '')
|
|
7
|
+
}, segment.text);
|
|
8
|
+
}));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 展示搜索结果
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export var SearchResult = function SearchResult(_ref) {
|
|
16
|
+
var results = _ref.results;
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: styles.searchResult
|
|
19
|
+
}, results.map(function (r) {
|
|
20
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: styles.item
|
|
22
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: styles.subject
|
|
24
|
+
}, r.subject), /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: styles.br
|
|
26
|
+
}), /*#__PURE__*/React.createElement("a", {
|
|
27
|
+
className: styles.result,
|
|
28
|
+
href: r.link
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: styles.title
|
|
31
|
+
}, getHighlightInfo(r.tilte)), /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: styles.description
|
|
33
|
+
}, getHighlightInfo(r.description))));
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.searchResult {
|
|
2
|
+
font-size: 12px;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: center;
|
|
6
|
+
min-width: 486px;
|
|
7
|
+
max-width: 512px;
|
|
8
|
+
max-height: 50vh;
|
|
9
|
+
overflow-x: hidden;
|
|
10
|
+
overflow-y: auto;
|
|
11
|
+
|
|
12
|
+
.item {
|
|
13
|
+
width: 100%;
|
|
14
|
+
display: flex;
|
|
15
|
+
margin: 6px 0;
|
|
16
|
+
position: relative;
|
|
17
|
+
|
|
18
|
+
.subject {
|
|
19
|
+
text-align: right;
|
|
20
|
+
padding: 4px;
|
|
21
|
+
flex-basis: 120px;
|
|
22
|
+
color: rgb(160, 161, 167);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.br {
|
|
26
|
+
flex-basis: 1px;
|
|
27
|
+
margin: 0 6px;
|
|
28
|
+
background-color: #873bf4;
|
|
29
|
+
opacity: 0.2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.result {
|
|
33
|
+
flex: 1;
|
|
34
|
+
min-width: 300px;
|
|
35
|
+
padding: 4px 0 4px 6px;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
|
|
40
|
+
&:hover {
|
|
41
|
+
background-color: #f9f0ff;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.title {
|
|
45
|
+
font-weight: 500;
|
|
46
|
+
color: #000;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.description {
|
|
50
|
+
font-size: 11px;
|
|
51
|
+
color: rgb(160, 161, 167);
|
|
52
|
+
max-height: 55px;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
.segment {
|
|
55
|
+
padding-left: 1px;
|
|
56
|
+
padding-right: 1px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.highlighted {
|
|
61
|
+
color: #873bf4;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|