@lobehub/ui 1.77.0 → 1.78.0
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/README.md +2 -2
- package/es/Highlighter/index.d.ts +2 -0
- package/es/Highlighter/index.js +8 -4
- package/es/Highlighter/style.js +4 -3
- package/es/Markdown/CodeBlock.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
<img height="120" src="https://
|
|
5
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
|
|
6
6
|
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
|
|
7
|
-
<img height="120" src="https://
|
|
7
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/lollipop.webp">
|
|
8
8
|
|
|
9
9
|
<h1>Lobe UI</h1>
|
|
10
10
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { type CopyButtonProps } from "../CopyButton";
|
|
2
3
|
import { DivProps } from "../types";
|
|
3
4
|
export interface HighlighterProps extends DivProps {
|
|
4
5
|
/**
|
|
5
6
|
* @description The code content to be highlighted
|
|
6
7
|
*/
|
|
7
8
|
children: string;
|
|
9
|
+
copyButtonSize?: CopyButtonProps['size'];
|
|
8
10
|
/**
|
|
9
11
|
* @description Whether to show the copy button
|
|
10
12
|
* @default true
|
package/es/Highlighter/index.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["children", "language", "className", "style", "copyable", "showLanguage", "type", "spotlight"];
|
|
3
|
+
var _excluded = ["copyButtonSize", "children", "language", "className", "style", "copyable", "showLanguage", "type", "spotlight"];
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
import { memo } from 'react';
|
|
7
7
|
import CopyButton from "../CopyButton";
|
|
8
8
|
import Spotlight from "../Spotlight";
|
|
9
|
+
import Tag from "../Tag";
|
|
9
10
|
import SyntaxHighlighter from "./SyntaxHighlighter";
|
|
10
11
|
import { useStyles } from "./style";
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
export var Highlighter = /*#__PURE__*/memo(function (_ref) {
|
|
14
|
-
var
|
|
15
|
+
var _ref$copyButtonSize = _ref.copyButtonSize,
|
|
16
|
+
copyButtonSize = _ref$copyButtonSize === void 0 ? 'site' : _ref$copyButtonSize,
|
|
17
|
+
children = _ref.children,
|
|
15
18
|
language = _ref.language,
|
|
16
19
|
className = _ref.className,
|
|
17
20
|
style = _ref.style,
|
|
@@ -37,8 +40,9 @@ export var Highlighter = /*#__PURE__*/memo(function (_ref) {
|
|
|
37
40
|
}), copyable && /*#__PURE__*/_jsx(CopyButton, {
|
|
38
41
|
className: styles.button,
|
|
39
42
|
content: children,
|
|
40
|
-
placement: "left"
|
|
41
|
-
|
|
43
|
+
placement: "left",
|
|
44
|
+
size: copyButtonSize
|
|
45
|
+
}), showLanguage && language && /*#__PURE__*/_jsx(Tag, {
|
|
42
46
|
className: styles.lang,
|
|
43
47
|
children: language.toLowerCase()
|
|
44
48
|
}), /*#__PURE__*/_jsx(SyntaxHighlighter, {
|
package/es/Highlighter/style.js
CHANGED
|
@@ -5,14 +5,15 @@ export var useStyles = createStyles(function (_ref, type) {
|
|
|
5
5
|
var token = _ref.token,
|
|
6
6
|
css = _ref.css,
|
|
7
7
|
cx = _ref.cx,
|
|
8
|
-
prefixCls = _ref.prefixCls
|
|
8
|
+
prefixCls = _ref.prefixCls,
|
|
9
|
+
stylish = _ref.stylish;
|
|
9
10
|
var prefix = "".concat(prefixCls, "-highlighter");
|
|
10
11
|
var buttonHoverCls = "".concat(prefix, "-hover-btn");
|
|
11
12
|
var langHoverCls = "".concat(prefix, "-hover-lang");
|
|
12
13
|
var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, type === 'block' ? token.colorFillTertiary : token.colorFillQuaternary);
|
|
13
14
|
return {
|
|
14
|
-
button: cx(buttonHoverCls, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n z-index:
|
|
15
|
+
button: cx(buttonHoverCls, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 2;\n top: ", ";\n right: ", ";\n\n opacity: 0;\n "])), type === 'pure' ? 0 : '8px', type === 'pure' ? 0 : '8px')),
|
|
15
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")),
|
|
16
|
-
lang: cx(langHoverCls, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: absolute;\n z-index:
|
|
17
|
+
lang: cx(langHoverCls, stylish.blur, css(_templateObject4 || (_templateObject4 = _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))
|
|
17
18
|
};
|
|
18
19
|
});
|
package/es/Markdown/CodeBlock.js
CHANGED
|
@@ -18,6 +18,10 @@ var Code = /*#__PURE__*/memo(function (properties) {
|
|
|
18
18
|
if (!children) return;
|
|
19
19
|
return /*#__PURE__*/_jsx(Highlighter, {
|
|
20
20
|
className: styles,
|
|
21
|
+
copyButtonSize: {
|
|
22
|
+
blockSize: 28,
|
|
23
|
+
fontSize: 16
|
|
24
|
+
},
|
|
21
25
|
language: (className === null || className === void 0 ? void 0 : className.replace('language-', '')) || 'markdown',
|
|
22
26
|
type: "block",
|
|
23
27
|
children: Array.isArray(children) ? children[0] : children
|