@lobehub/ui 2.13.1 → 2.13.3

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.
@@ -5,10 +5,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { visit } from 'unist-util-visit';
8
+ var DEFAULT_ALLOW_HTML_TAGS = ['sub', 'sup', 'ins', 'kbd', 'b', 'strong', 'i', 'em', 'mark', 'del', 'u'];
8
9
  export var remarkGfmPlus = function remarkGfmPlus() {
9
10
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10
11
  var _options$allowHtmlTag = options.allowHtmlTags,
11
- allowHtmlTags = _options$allowHtmlTag === void 0 ? ['sub', 'sup', 'ins', 'kbd'] : _options$allowHtmlTag;
12
+ allowHtmlTags = _options$allowHtmlTag === void 0 ? DEFAULT_ALLOW_HTML_TAGS : _options$allowHtmlTag;
12
13
  return function (tree) {
13
14
  // 遍历所有父节点,查找分离的HTML标签模式
14
15
  visit(tree, function (node) {
@@ -1,5 +1,13 @@
1
1
  import { renderToString } from 'katex';
2
2
 
3
+ // Helper: replace unescaped pipes with \vert within a LaTeX math fragment
4
+ var replaceUnescapedPipes = function replaceUnescapedPipes(formula) {
5
+ return (
6
+ // Use \vert{} so the control sequence terminates before the next token
7
+ formula.replaceAll(/(?<!\\)\|/g, '\\vert{}')
8
+ );
9
+ };
10
+
3
11
  /**
4
12
  * Converts LaTeX bracket delimiters to dollar sign delimiters.
5
13
  * Converts \[...\] to $$...$$ and \(...\) to $...$
@@ -40,9 +48,16 @@ export function escapeMhchemCommands(text) {
40
48
  * @returns The string with pipe characters escaped in LaTeX expressions
41
49
  */
42
50
  export function escapeLatexPipes(text) {
43
- // According to the failing test, we should not escape pipes in LaTeX expressions
44
- // This function is now a no-op but is kept for backward compatibility
45
- return text;
51
+ // Replace unescaped '|' inside LaTeX math spans with '\vert' so that
52
+ // remark-gfm table parsing won't treat them as column separators.
53
+ // Leave code blocks/inline code untouched.
54
+ var pattern = /(```[\S\s]*?```|`[^\n`]*`)|\$\$([\S\s]*?)\$\$|(?<!\$)\$(?!\$)([\S\s]*?)(?<!\$)\$(?!\$)/g;
55
+ return text.replaceAll(pattern, function (match, code, display, inline) {
56
+ if (code !== undefined) return code; // preserve code fences/inline code
57
+ if (display !== undefined) return "$$".concat(replaceUnescapedPipes(display), "$$");
58
+ if (inline !== undefined) return "$".concat(replaceUnescapedPipes(inline), "$");
59
+ return match;
60
+ });
46
61
  }
47
62
 
48
63
  /**
@@ -9,7 +9,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
9
  import { useMemo, useRef, useState } from 'react';
10
10
  import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider";
11
11
  import { isLastFormulaRenderable } from "./latex";
12
- import { addToCache, contentCache, preprocessContent } from "./utils";
12
+ import { addToCache, contentCache, preprocessMarkdownContent } from "./utils";
13
13
  export var useMarkdownContent = function useMarkdownContent(children) {
14
14
  var _useMarkdownContext = useMarkdownContext(),
15
15
  animated = _useMarkdownContext.animated,
@@ -37,7 +37,7 @@ export var useMarkdownContent = function useMarkdownContent(children) {
37
37
  }
38
38
 
39
39
  // Process new content only if needed
40
- var processedContent = preprocessContent(children, {
40
+ var processedContent = preprocessMarkdownContent(children, {
41
41
  citationsLength: citationsLength,
42
42
  enableCustomFootnotes: enableCustomFootnotes,
43
43
  enableLatex: enableLatex
@@ -13,7 +13,6 @@ import remarkGfm from 'remark-gfm';
13
13
  import remarkMath from 'remark-math';
14
14
  import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider";
15
15
  import { remarkBr } from "../../Markdown/plugins/remarkBr";
16
- import { remarkColor } from "../../Markdown/plugins/remarkColor";
17
16
  import { remarkCustomFootnotes } from "../../Markdown/plugins/remarkCustomFootnotes";
18
17
  import { remarkGfmPlus } from "../../Markdown/plugins/remarkGfmPlus";
19
18
  import { remarkVideo } from "../../Markdown/plugins/remarkVideo";
@@ -29,9 +28,11 @@ export var useMarkdownRemarkPlugins = function useMarkdownRemarkPlugins() {
29
28
  allowHtml = _useMarkdownContext.allowHtml;
30
29
  var isChatMode = variant === 'chat';
31
30
  var memoPlugins = useMemo(function () {
32
- return [remarkCjkFriendly, [remarkGfm, {
31
+ return [remarkCjkFriendly,
32
+ // Parse math before GFM so that '|' inside $...$ isn't treated as a table separator
33
+ enableLatex && remarkMath, [remarkGfm, {
33
34
  singleTilde: false
34
- }], !allowHtml && remarkBr, !allowHtml && remarkGfmPlus, !allowHtml && remarkVideo, remarkColor, enableLatex && remarkMath, enableCustomFootnotes && remarkCustomFootnotes, isChatMode && remarkBreaks].filter(Boolean);
35
+ }], !allowHtml && remarkBr, !allowHtml && remarkGfmPlus, !allowHtml && remarkVideo, enableCustomFootnotes && remarkCustomFootnotes, isChatMode && remarkBreaks].filter(Boolean);
35
36
  }, [allowHtml, isChatMode, enableLatex, enableCustomFootnotes]);
36
37
  return useMemo(function () {
37
38
  return [].concat(_toConsumableArray(remarkPluginsAhead), _toConsumableArray(memoPlugins), _toConsumableArray(remarkPlugins));
@@ -26,5 +26,5 @@ interface PreprocessOptions {
26
26
  enableCustomFootnotes?: boolean;
27
27
  enableLatex?: boolean;
28
28
  }
29
- export declare const preprocessContent: (str: string, { enableCustomFootnotes, enableLatex, citationsLength }?: PreprocessOptions) => string;
29
+ export declare const preprocessMarkdownContent: (str: string, { enableCustomFootnotes, enableLatex, citationsLength }?: PreprocessOptions) => string;
30
30
  export {};
@@ -117,7 +117,7 @@ export var transformCitations = function transformCitations(rawContent) {
117
117
  * Preprocessing options for markdown content
118
118
  */
119
119
 
120
- export var preprocessContent = function preprocessContent(str) {
120
+ export var preprocessMarkdownContent = function preprocessMarkdownContent(str) {
121
121
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
122
122
  enableCustomFootnotes = _ref.enableCustomFootnotes,
123
123
  enableLatex = _ref.enableLatex,
package/es/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export { default as GroupAvatar, type GroupAvatarProps } from './GroupAvatar';
29
29
  export { default as GuideCard, type GuideCardProps } from './GuideCard';
30
30
  export { default as Header, type HeaderProps } from './Header';
31
31
  export { default as Highlighter, type HighlighterProps, highlighterThemes, SyntaxHighlighter, type SyntaxHighlighterProps, } from './Highlighter';
32
+ export { preprocessMarkdownContent } from './hooks/useMarkdown/utils';
32
33
  export { combineKeys, default as Hotkey, type HotkeyProps, KeyMapEnum } from './Hotkey';
33
34
  export { default as HotkeyInput, type HotkeyInputProps } from './HotkeyInput';
34
35
  export { default as Icon, type IconProps, IconProvider, type IconSize } from './Icon';
@@ -39,6 +40,14 @@ export { default as Layout, LayoutFooter, type LayoutFooterProps, LayoutHeader,
39
40
  export { default as List, ListItem, type ListItemProps, type ListProps } from './List';
40
41
  export { default as Markdown, type MarkdownProps, Typography, type TypographyProps, } from './Markdown';
41
42
  export { default as SearchResultCards, type SearchResultCardsProps, } from './Markdown/components/SearchResultCards';
43
+ export { rehypeCustomFootnotes } from './Markdown/plugins/rehypeCustomFootnotes';
44
+ export { rehypeKatexDir } from './Markdown/plugins/rehypeKatexDir';
45
+ export { rehypeStreamAnimated } from './Markdown/plugins/rehypeStreamAnimated';
46
+ export { remarkBr } from './Markdown/plugins/remarkBr';
47
+ export { remarkColor } from './Markdown/plugins/remarkColor';
48
+ export { remarkCustomFootnotes } from './Markdown/plugins/remarkCustomFootnotes';
49
+ export { remarkGfmPlus } from './Markdown/plugins/remarkGfmPlus';
50
+ export { remarkVideo } from './Markdown/plugins/remarkVideo';
42
51
  export { default as MaskShadow, type MaskShadowProps } from './MaskShadow';
43
52
  export { default as MaterialFileTypeIcon, type MaterialFileTypeIconProps, } from './MaterialFileTypeIcon';
44
53
  export { type ItemType, default as Menu, type MenuInfo, type MenuItemType, type MenuProps, } from './Menu';
package/es/index.js CHANGED
@@ -29,6 +29,7 @@ export { default as GroupAvatar } from "./GroupAvatar";
29
29
  export { default as GuideCard } from "./GuideCard";
30
30
  export { default as Header } from "./Header";
31
31
  export { default as Highlighter, highlighterThemes, SyntaxHighlighter } from "./Highlighter";
32
+ export { preprocessMarkdownContent } from "./hooks/useMarkdown/utils";
32
33
  export { combineKeys, default as Hotkey, KeyMapEnum } from "./Hotkey";
33
34
  export { default as HotkeyInput } from "./HotkeyInput";
34
35
  export { default as Icon, IconProvider } from "./Icon";
@@ -39,6 +40,14 @@ export { default as Layout, LayoutFooter, LayoutHeader, LayoutMain, LayoutSideba
39
40
  export { default as List, ListItem } from "./List";
40
41
  export { default as Markdown, Typography } from "./Markdown";
41
42
  export { default as SearchResultCards } from "./Markdown/components/SearchResultCards";
43
+ export { rehypeCustomFootnotes } from "./Markdown/plugins/rehypeCustomFootnotes";
44
+ export { rehypeKatexDir } from "./Markdown/plugins/rehypeKatexDir";
45
+ export { rehypeStreamAnimated } from "./Markdown/plugins/rehypeStreamAnimated";
46
+ export { remarkBr } from "./Markdown/plugins/remarkBr";
47
+ export { remarkColor } from "./Markdown/plugins/remarkColor";
48
+ export { remarkCustomFootnotes } from "./Markdown/plugins/remarkCustomFootnotes";
49
+ export { remarkGfmPlus } from "./Markdown/plugins/remarkGfmPlus";
50
+ export { remarkVideo } from "./Markdown/plugins/remarkVideo";
42
51
  export { default as MaskShadow } from "./MaskShadow";
43
52
  export { default as MaterialFileTypeIcon } from "./MaterialFileTypeIcon";
44
53
  export { default as Menu } from "./Menu";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.13.1",
3
+ "version": "2.13.3",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -52,33 +52,33 @@
52
52
  "@dnd-kit/utilities": "^3.2.2",
53
53
  "@emoji-mart/data": "^1.2.1",
54
54
  "@emoji-mart/react": "^1.1.1",
55
- "@floating-ui/react": "^0.27.14",
55
+ "@floating-ui/react": "^0.27.16",
56
56
  "@giscus/react": "^3.1.0",
57
57
  "@lobehub/fluent-emoji": "^2.0.0",
58
- "@lobehub/icons": "^2.19.0",
59
- "@mdx-js/mdx": "^3.1.0",
60
- "@mdx-js/react": "^3.1.0",
58
+ "@lobehub/icons": "^2.33.0",
59
+ "@mdx-js/mdx": "^3.1.1",
60
+ "@mdx-js/react": "^3.1.1",
61
61
  "@radix-ui/react-slot": "^1.2.3",
62
- "@shikijs/transformers": "^3.8.1",
62
+ "@shikijs/transformers": "^3.12.2",
63
63
  "@splinetool/runtime": "0.9.526",
64
- "ahooks": "^3.9.0",
64
+ "ahooks": "^3.9.5",
65
65
  "antd-style": "^3.7.1",
66
66
  "chroma-js": "^3.1.2",
67
67
  "class-variance-authority": "^0.7.1",
68
- "dayjs": "^1.11.13",
68
+ "dayjs": "^1.11.18",
69
69
  "emoji-mart": "^5.6.0",
70
70
  "fast-deep-equal": "^3.1.3",
71
- "framer-motion": "^12.23.11",
72
- "immer": "^10.1.1",
71
+ "framer-motion": "^12.23.13",
72
+ "immer": "^10.1.3",
73
73
  "katex": "^0.16.22",
74
74
  "leva": "^0.10.0",
75
75
  "lodash-es": "^4.17.21",
76
76
  "lucide-react": "^0.543.0",
77
- "marked": "^16.2.0",
78
- "mermaid": "^11.9.0",
77
+ "marked": "^16.3.0",
78
+ "mermaid": "^11.11.0",
79
79
  "numeral": "^2.0.6",
80
80
  "polished": "^4.3.1",
81
- "query-string": "^9.2.2",
81
+ "query-string": "^9.3.0",
82
82
  "rc-collapse": "^4.0.0",
83
83
  "rc-footer": "^0.6.8",
84
84
  "rc-image": "^7.12.0",
@@ -100,9 +100,9 @@
100
100
  "remark-gfm": "^4.0.1",
101
101
  "remark-github": "^12.0.0",
102
102
  "remark-math": "^6.0.0",
103
- "shiki": "^3.8.1",
104
- "swr": "^2.3.4",
105
- "ts-md5": "^2.0.0",
103
+ "shiki": "^3.12.2",
104
+ "swr": "^2.3.6",
105
+ "ts-md5": "^2.0.1",
106
106
  "unified": "^11.0.5",
107
107
  "url-join": "^5.0.0",
108
108
  "use-merge-value": "^1.2.0",