@lobehub/ui 1.94.5 → 1.94.6
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.
|
@@ -22,10 +22,14 @@ var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
|
|
|
22
22
|
data = _useHighlight.data,
|
|
23
23
|
isLoading = _useHighlight.isLoading;
|
|
24
24
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
25
|
-
children: [isLoading ? /*#__PURE__*/_jsx("
|
|
25
|
+
children: [isLoading ? /*#__PURE__*/_jsx("div", {
|
|
26
26
|
className: cx(styles.unshiki, className),
|
|
27
27
|
style: style,
|
|
28
|
-
children:
|
|
28
|
+
children: /*#__PURE__*/_jsx("pre", {
|
|
29
|
+
children: /*#__PURE__*/_jsx("code", {
|
|
30
|
+
children: children
|
|
31
|
+
})
|
|
32
|
+
})
|
|
29
33
|
}) : /*#__PURE__*/_jsx("div", {
|
|
30
34
|
className: cx(styles.shiki, className),
|
|
31
35
|
dangerouslySetInnerHTML: {
|
|
@@ -12,6 +12,6 @@ export var useStyles = createStyles(function (_ref) {
|
|
|
12
12
|
loading: cx(stylish.blur, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 10;\n top: 0;\n right: 0;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n height: 34px;\n padding: 0 8px;\n\n font-family: ", ";\n color: ", ";\n\n border-radius: ", ";\n "])), token.fontFamilyCode, token.colorTextTertiary, token.borderRadius)),
|
|
13
13
|
prism: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n pre {\n overflow: auto;\n font-family: ", " !important;\n }\n "])), token.fontFamilyCode),
|
|
14
14
|
shiki: cx("".concat(prefix, "-shiki"), css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin: 0;\n padding: 0;\n\n .shiki {\n overflow-x: auto;\n margin: 0;\n padding: 0;\n background: none !important;\n }\n "])))),
|
|
15
|
-
unshiki: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n
|
|
15
|
+
unshiki: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextDescription)
|
|
16
16
|
};
|
|
17
17
|
});
|
package/es/Highlighter/style.js
CHANGED
|
@@ -16,6 +16,6 @@ export var useStyles = createStyles(function (_ref, type) {
|
|
|
16
16
|
container: cx(prefix, type !== 'pure' && typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n overflow: auto;\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n margin: 0 !important;\n padding: ", " !important;\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n "])), token.borderRadius, token.motionEaseOut, buttonHoverCls, langHoverCls, type === 'pure' ? 0 : "16px 24px")),
|
|
17
17
|
header: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 4px 8px;\n background: ", ";\n "])), token.colorFillQuaternary),
|
|
18
18
|
lang: cx(langHoverCls, stylish.blur, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 2;\n right: 0;\n bottom: 8px;\n\n font-family: ", ";\n color: ", ";\n\n opacity: 0;\n\n transition: opacity 0.1s;\n "])), token.fontFamilyCode, token.colorTextSecondary)),
|
|
19
|
-
select: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .ant-select-selection-item {\n min-width: 100px;\n padding-inline-end: 0 !important;\n color: ", ";\n text-align: center;\n }\n
|
|
19
|
+
select: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .ant-select-selection-item {\n min-width: 100px;\n padding-inline-end: 0 !important;\n color: ", ";\n text-align: center;\n }\n "])), token.colorTextDescription)
|
|
20
20
|
};
|
|
21
21
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: readonly ["abap", "actionscript-3", "ada", "apache", "apex", "apl", "applescript", "ara", "asm", "astro", "awk", "ballerina", "bat", "beancount", "berry", "bibtex", "bicep", "blade", "c", "cadence", "clarity", "clojure", "cmake", "cobol", "codeql", "coffee", "cpp", "crystal", "csharp", "css", "cue", "cypher", "d", "dart", "dax", "diff", "docker", "dream-maker", "elixir", "elm", "erb", "erlang", "fish", "fsharp", "gdresource", "gdscript", "gdshader", "gherkin", "git-commit", "git-rebase", "glimmer-js", "glimmer-ts", "glsl", "gnuplot", "go", "graphql", "groovy", "hack", "haml", "handlebars", "haskell", "hcl", "hjson", "hlsl", "html", "http", "imba", "ini", "java", "javascript", "jinja-html", "jison", "json", "json5", "jsonc", "jsonl", "jsonnet", "jssm", "jsx", "julia", "kotlin", "kusto", "latex", "less", "liquid", "lisp", "logo", "lua", "make", "markdown", "marko", "matlab", "mdc", "mdx", "mermaid", "mojo", "narrat", "nextflow", "nginx", "nim", "nix", "objective-c", "objective-cpp", "ocaml", "pascal", "perl", "php", "plsql", "postcss", "powerquery", "powershell", "prisma", "prolog", "proto", "pug", "puppet", "purescript", "python", "r", "raku", "razor", "reg", "rel", "riscv", "rst", "ruby", "rust", "sas", "sass", "scala", "scheme", "scss", "shaderlab", "shellscript", "shellsession", "smalltalk", "solidity", "sparql", "splunk", "sql", "ssh-config", "stata", "stylus", "svelte", "swift", "system-verilog", "tasl", "tcl", "tex", "toml", "tsx", "turtle", "twig", "typescript", "v", "vb", "verilog", "vhdl", "viml", "vue", "vue-html", "vyper", "wasm", "wenyan", "wgsl", "wolfram", "xml", "xsl", "yaml", "zenscript", "zig", "bash", "batch", "be", "c#", "cdc", "clj", "cmd", "console", "cql", "cs", "dockerfile", "erl", "f#", "fs", "fsl", "gjs", "gts", "hbs", "hs", "jade", "js", "kql", "makefile", "md", "nar", "nf", "objc", "perl6", "properties", "ps", "ps1", "py", "ql", "rb", "rs", "sh", "shader", "shell", "spl", "styl", "ts", "vim", "vimscript", "vy", "yml", "zsh", "文言"];
|
|
2
2
|
export default _default;
|
package/es/hooks/useHighlight.js
CHANGED
|
@@ -3,89 +3,67 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
import { getHighlighter } from 'shikiji';
|
|
4
4
|
import useSWR from 'swr';
|
|
5
5
|
import { themeConfig } from "../Highlighter/theme";
|
|
6
|
-
import languageMap from "./languageMap";
|
|
7
6
|
export var FALLBACK_LANG = 'markdown';
|
|
8
|
-
var FALLBACK_LANGS = [
|
|
9
|
-
var THEME = [themeConfig(true), themeConfig(false)];
|
|
7
|
+
var FALLBACK_LANGS = [FALLBACK_LANG];
|
|
10
8
|
var cacheHighlighter;
|
|
11
9
|
var initHighlighter = /*#__PURE__*/function () {
|
|
12
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
10
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(lang) {
|
|
13
11
|
var highlighter;
|
|
14
12
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
13
|
while (1) switch (_context.prev = _context.next) {
|
|
16
14
|
case 0:
|
|
17
15
|
highlighter = cacheHighlighter;
|
|
18
|
-
if (!highlighter) {
|
|
16
|
+
if (!(highlighter && FALLBACK_LANGS.includes(lang))) {
|
|
19
17
|
_context.next = 5;
|
|
20
18
|
break;
|
|
21
19
|
}
|
|
22
20
|
return _context.abrupt("return", highlighter);
|
|
23
21
|
case 5:
|
|
24
|
-
|
|
22
|
+
FALLBACK_LANGS.push(lang);
|
|
23
|
+
_context.next = 8;
|
|
25
24
|
return getHighlighter({
|
|
26
25
|
langs: FALLBACK_LANGS,
|
|
27
|
-
themes:
|
|
26
|
+
themes: [themeConfig(true), themeConfig(false)]
|
|
28
27
|
});
|
|
29
|
-
case
|
|
28
|
+
case 8:
|
|
30
29
|
highlighter = _context.sent;
|
|
31
30
|
cacheHighlighter = highlighter;
|
|
32
31
|
return _context.abrupt("return", highlighter);
|
|
33
|
-
case
|
|
32
|
+
case 11:
|
|
34
33
|
case "end":
|
|
35
34
|
return _context.stop();
|
|
36
35
|
}
|
|
37
36
|
}, _callee);
|
|
38
37
|
}));
|
|
39
|
-
return function initHighlighter() {
|
|
38
|
+
return function initHighlighter(_x) {
|
|
40
39
|
return _ref.apply(this, arguments);
|
|
41
40
|
};
|
|
42
41
|
}();
|
|
43
42
|
export var useHighlight = function useHighlight(text, language, isDarkMode) {
|
|
44
43
|
return useSWR([text, language, Number(isDarkMode)].join('-'), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
45
|
-
var
|
|
44
|
+
var highlighter, html;
|
|
46
45
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
47
46
|
while (1) switch (_context2.prev = _context2.next) {
|
|
48
47
|
case 0:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return initHighlighter();
|
|
54
|
-
case 5:
|
|
48
|
+
_context2.prev = 0;
|
|
49
|
+
_context2.next = 3;
|
|
50
|
+
return initHighlighter(language);
|
|
51
|
+
case 3:
|
|
55
52
|
highlighter = _context2.sent;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
if (!languageMap.includes(lang)) {
|
|
61
|
-
_context2.next = 12;
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
_context2.next = 10;
|
|
65
|
-
return highlighter === null || highlighter === void 0 ? void 0 : highlighter.loadLanguage(lang);
|
|
66
|
-
case 10:
|
|
67
|
-
_context2.next = 13;
|
|
68
|
-
break;
|
|
69
|
-
case 12:
|
|
70
|
-
lang = FALLBACK_LANG;
|
|
71
|
-
case 13:
|
|
72
|
-
_context2.next = 15;
|
|
73
|
-
return highlighter === null || highlighter === void 0 ? void 0 : highlighter.codeToHtml(text, {
|
|
74
|
-
lang: lang,
|
|
75
|
-
theme: theme
|
|
53
|
+
html = highlighter === null || highlighter === void 0 ? void 0 : highlighter.codeToHtml(text, {
|
|
54
|
+
lang: language,
|
|
55
|
+
theme: isDarkMode ? 'dark' : 'light'
|
|
76
56
|
});
|
|
77
|
-
case 15:
|
|
78
|
-
html = _context2.sent;
|
|
79
57
|
return _context2.abrupt("return", html);
|
|
80
|
-
case
|
|
81
|
-
_context2.prev =
|
|
82
|
-
_context2.t0 = _context2["catch"](
|
|
83
|
-
return _context2.abrupt("return", "<code>".concat(text, "</code>"));
|
|
84
|
-
case
|
|
58
|
+
case 8:
|
|
59
|
+
_context2.prev = 8;
|
|
60
|
+
_context2.t0 = _context2["catch"](0);
|
|
61
|
+
return _context2.abrupt("return", "<pre><code>".concat(text, "</code></pre>"));
|
|
62
|
+
case 11:
|
|
85
63
|
case "end":
|
|
86
64
|
return _context2.stop();
|
|
87
65
|
}
|
|
88
|
-
}, _callee2, null, [[
|
|
66
|
+
}, _callee2, null, [[0, 8]]);
|
|
89
67
|
})));
|
|
90
68
|
};
|
|
91
69
|
export { default as languageMap } from "./languageMap";
|