@lobehub/ui 1.164.6 → 1.164.8

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.
@@ -16,6 +16,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
16
16
  import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
17
17
  import { Flexbox } from 'react-layout-kit';
18
18
  import { useStyles } from "./style";
19
+ import { isMacLike } from "../utils/platform";
19
20
  import SyntaxHighlighter from "../Highlighter/SyntaxHighlighter";
20
21
  import { jsx as _jsx } from "react/jsx-runtime";
21
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -29,7 +30,6 @@ var KEYCODE_BACK_QUOTE = 192;
29
30
  var HISTORY_LIMIT = 100;
30
31
  var HISTORY_TIME_GAP = 3000;
31
32
  var isWindows = typeof window !== 'undefined' && 'navigator' in window && /win/i.test(navigator.platform);
32
- var isMacLike = typeof window !== 'undefined' && 'navigator' in window && /(mac|iphone|ipod|ipad)/i.test(navigator.platform);
33
33
  var getLines = function getLines(text, position) {
34
34
  return text.slice(0, Math.max(0, position)).split('\n');
35
35
  };
@@ -28,6 +28,7 @@ import Link from "../mdx/mdxComponents/Link";
28
28
  import Video from "../mdx/mdxComponents/Video";
29
29
  import { CodeFullFeatured, CodeLite } from "./CodeBlock";
30
30
  import { useStyles as useMarkdownStyles } from "./markdown.style";
31
+ import { rehypeKatexDir } from "./rehypePlugin";
31
32
  import { useStyles } from "./style";
32
33
  import { escapeBrackets, escapeMhchem, fixMarkdownBold } from "./utils";
33
34
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -108,7 +109,7 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
108
109
  }, [].concat(_toConsumableArray(Object.values(components || {})), _toConsumableArray(Object.values(componentProps || {})), [enableImageGallery, enableMermaid, fullFeaturedCodeBlock]));
109
110
  var innerRehypePlugins = Array.isArray(rehypePlugins) ? rehypePlugins : [rehypePlugins];
110
111
  var memoRehypePlugins = useMemo(function () {
111
- return [allowHtml && rehypeRaw, enableLatex && rehypeKatex].concat(_toConsumableArray(innerRehypePlugins)).filter(Boolean);
112
+ return [allowHtml && rehypeRaw, enableLatex && rehypeKatex, enableLatex && rehypeKatexDir].concat(_toConsumableArray(innerRehypePlugins)).filter(Boolean);
112
113
  }, [allowHtml, enableLatex].concat(_toConsumableArray(innerRehypePlugins)));
113
114
  var innerRemarkPlugins = Array.isArray(remarkPlugins) ? remarkPlugins : [remarkPlugins];
114
115
  var memoRemarkPlugins = useMemo(function () {
@@ -0,0 +1,2 @@
1
+ import type { Node } from 'unist';
2
+ export declare const rehypeKatexDir: () => (tree: Node) => void;
@@ -0,0 +1,16 @@
1
+ // katex-directive
2
+ // 给 class="katex" 的节点加上 dir="ltr" 属性
3
+
4
+ import { visit } from 'unist-util-visit';
5
+
6
+ // eslint-disable-next-line unicorn/consistent-function-scoping
7
+ export var rehypeKatexDir = function rehypeKatexDir() {
8
+ return function (tree) {
9
+ visit(tree, 'element', function (node) {
10
+ var _node$properties;
11
+ if ((_node$properties = node.properties) !== null && _node$properties !== void 0 && (_node$properties = _node$properties.className) !== null && _node$properties !== void 0 && _node$properties.includes('katex')) {
12
+ node.properties.dir = 'ltr';
13
+ }
14
+ });
15
+ };
16
+ };
@@ -30,7 +30,7 @@ var Swatches = /*#__PURE__*/memo(function (_ref) {
30
30
  style: {
31
31
  background: theme.colorBgContainer
32
32
  }
33
- }), colors.map(function (c) {
33
+ }), colors.map(function (c, index) {
34
34
  var isActive = c === activeColor;
35
35
  return /*#__PURE__*/_jsx(Flexbox, {
36
36
  className: cx(styles.container, isActive && styles.active),
@@ -40,7 +40,7 @@ var Swatches = /*#__PURE__*/memo(function (_ref) {
40
40
  style: {
41
41
  background: c
42
42
  }
43
- }, c);
43
+ }, "".concat(c, "_").concat(index));
44
44
  })]
45
45
  });
46
46
  });
@@ -72,6 +72,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
72
72
  setTyping(false);
73
73
  },
74
74
  placeholder: placeholder,
75
+ shortcut: true,
75
76
  style: stylesProps === null || stylesProps === void 0 ? void 0 : stylesProps.input,
76
77
  text: text,
77
78
  textareaClassname: classNames === null || classNames === void 0 ? void 0 : classNames.input,
@@ -29,6 +29,7 @@ export interface MessageInputProps extends DivProps {
29
29
  * @param text - The text input by the user.
30
30
  */
31
31
  renderButtons?: (text: string) => ButtonProps[];
32
+ shortcut?: boolean;
32
33
  text?: {
33
34
  cancel?: string;
34
35
  confirm?: string;
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "style", "editButtonSize", "classNames"];
4
+ var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "style", "editButtonSize", "classNames", "shortcut"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -16,13 +16,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
16
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
17
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
18
  import { Button } from 'antd';
19
+ import { ChevronUpIcon, CommandIcon, CornerDownLeft } from 'lucide-react';
19
20
  import { memo, useState } from 'react';
20
21
  import { Flexbox } from 'react-layout-kit';
22
+ import Icon from "../../Icon";
21
23
  import { TextArea } from "../../Input";
24
+ import { isMacLike } from "../../utils/platform";
22
25
  import { useStyles } from "./style";
23
26
  import { jsx as _jsx } from "react/jsx-runtime";
24
- import { Fragment as _Fragment } from "react/jsx-runtime";
25
27
  import { jsxs as _jsxs } from "react/jsx-runtime";
28
+ import { Fragment as _Fragment } from "react/jsx-runtime";
26
29
  var MessageInput = /*#__PURE__*/memo(function (_ref) {
27
30
  var text = _ref.text,
28
31
  _ref$type = _ref.type,
@@ -40,6 +43,7 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
40
43
  _ref$editButtonSize = _ref.editButtonSize,
41
44
  editButtonSize = _ref$editButtonSize === void 0 ? 'middle' : _ref$editButtonSize,
42
45
  classNames = _ref.classNames,
46
+ shortcut = _ref.shortcut,
43
47
  rest = _objectWithoutProperties(_ref, _excluded);
44
48
  var _useState = useState(defaultValue || ''),
45
49
  _useState2 = _slicedToArray(_useState, 2),
@@ -66,6 +70,11 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
66
70
  onChange: function onChange(e) {
67
71
  return setValue(e.target.value);
68
72
  },
73
+ onPressEnter: shortcut ? function (e) {
74
+ if (isMacLike ? e.metaKey : e.ctrlKey) {
75
+ onConfirm === null || onConfirm === void 0 || onConfirm(temporaryValue);
76
+ }
77
+ } : undefined,
69
78
  placeholder: placeholder,
70
79
  resize: false,
71
80
  style: textareaStyle,
@@ -79,13 +88,27 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
79
88
  size: "small"
80
89
  }, buttonProps), index);
81
90
  }) : /*#__PURE__*/_jsxs(_Fragment, {
82
- children: [/*#__PURE__*/_jsx(Button, {
91
+ children: [/*#__PURE__*/_jsxs(Button, {
83
92
  onClick: function onClick() {
84
93
  onConfirm === null || onConfirm === void 0 || onConfirm(temporaryValue);
85
94
  },
86
95
  size: editButtonSize,
87
96
  type: "primary",
88
- children: (text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm'
97
+ children: [(text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm', shortcut && /*#__PURE__*/_jsxs(Flexbox, {
98
+ gap: 4,
99
+ horizontal: true,
100
+ children: [/*#__PURE__*/_jsx(Icon, {
101
+ icon: isMacLike ? CommandIcon : ChevronUpIcon,
102
+ size: {
103
+ fontSize: 12
104
+ }
105
+ }), /*#__PURE__*/_jsx(Icon, {
106
+ icon: CornerDownLeft,
107
+ size: {
108
+ fontSize: 12
109
+ }
110
+ })]
111
+ })]
89
112
  }), /*#__PURE__*/_jsx(Button, {
90
113
  onClick: onCancel,
91
114
  size: editButtonSize,
@@ -0,0 +1 @@
1
+ export declare const isMacLike: boolean;
@@ -0,0 +1 @@
1
+ export var isMacLike = typeof window !== 'undefined' && 'navigator' in window && /(mac|iphone|ipod|ipad)/i.test(navigator.platform);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.164.6",
3
+ "version": "1.164.8",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",