@yuhuanowo/yunui 0.2.14 → 0.2.16
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 +19 -1
- package/README.zh-CN.md +17 -1
- package/README.zh-TW.md +17 -1
- package/dist/adapters.js +1 -1
- package/dist/ai.js +142 -103
- package/dist/ai.js.map +1 -1
- package/dist/chat.d.ts +133 -0
- package/dist/chat.js +268 -0
- package/dist/chat.js.map +1 -0
- package/dist/{chunk-U2LNRVMI.js → chunk-3RT24MSH.js} +4 -3
- package/dist/chunk-3RT24MSH.js.map +1 -0
- package/dist/chunk-5E3O6ANF.js +1154 -0
- package/dist/chunk-5E3O6ANF.js.map +1 -0
- package/dist/{chunk-VXFEANVX.js → chunk-5TOGZTAO.js} +333 -875
- package/dist/chunk-5TOGZTAO.js.map +1 -0
- package/dist/chunk-AV5TGEJS.js +54 -0
- package/dist/chunk-AV5TGEJS.js.map +1 -0
- package/dist/{chunk-GHO4RCDR.js → chunk-GSPJ5YI6.js} +57 -28
- package/dist/chunk-GSPJ5YI6.js.map +1 -0
- package/dist/chunk-QEIBYOG2.js +188 -0
- package/dist/chunk-QEIBYOG2.js.map +1 -0
- package/dist/{chunk-N53PNMPJ.js → chunk-UYYG4XDW.js} +3 -3
- package/dist/{chunk-N53PNMPJ.js.map → chunk-UYYG4XDW.js.map} +1 -1
- package/dist/content.d.ts +144 -0
- package/dist/content.js +890 -0
- package/dist/content.js.map +1 -0
- package/dist/index.d.ts +273 -6
- package/dist/index.js +5 -3
- package/dist/patterns.d.ts +107 -1
- package/dist/patterns.js +463 -10
- package/dist/patterns.js.map +1 -1
- package/package.json +77 -5
- package/styles/content.css +129 -0
- package/styles/tokens.css +704 -352
- package/styles/yunui.css +126 -4
- package/dist/chunk-GHO4RCDR.js.map +0 -1
- package/dist/chunk-U2LNRVMI.js.map +0 -1
- package/dist/chunk-VXFEANVX.js.map +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface CodeBlockEditPayload {
|
|
4
|
+
code: string;
|
|
5
|
+
language: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
}
|
|
8
|
+
interface CodeBlockProps {
|
|
9
|
+
children: string;
|
|
10
|
+
language?: string;
|
|
11
|
+
showLineNumbers?: boolean;
|
|
12
|
+
highlightLines?: number[];
|
|
13
|
+
filename?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* When provided, an "Edit" button appears in the header and calls this with
|
|
17
|
+
* the code payload (e.g. to open it in an editor/workspace). Hidden if unset.
|
|
18
|
+
*/
|
|
19
|
+
onEdit?: (payload: CodeBlockEditPayload) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Syntax-highlighted code block powered by Shiki (accurate, VS Code-grade
|
|
23
|
+
* highlighting for 100+ languages). Shiki is loaded on demand the first time a
|
|
24
|
+
* block renders, so it never ships in the initial bundle. Supports line numbers,
|
|
25
|
+
* highlighted lines, a filename header, copy, and an optional edit action.
|
|
26
|
+
*/
|
|
27
|
+
declare function CodeBlock({ children, language, showLineNumbers, highlightLines, filename, className, onEdit, }: CodeBlockProps): React.JSX.Element;
|
|
28
|
+
/** Inline code (`` `code` ``) — used by the markdown renderer. */
|
|
29
|
+
declare function InlineCode({ children, className, }: {
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
}): React.JSX.Element;
|
|
33
|
+
|
|
34
|
+
interface MarkdownRendererProps {
|
|
35
|
+
content: string;
|
|
36
|
+
className?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Rewrite image/link URLs before rendering (e.g. prefix a backend host or
|
|
39
|
+
* proxy). Defaults to identity.
|
|
40
|
+
*/
|
|
41
|
+
urlTransform?: (url: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* When provided, code blocks show an "Edit" button that calls this with the
|
|
44
|
+
* code payload (e.g. open it in an editor). Hidden if unset.
|
|
45
|
+
*/
|
|
46
|
+
onCodeEdit?: (payload: CodeBlockEditPayload) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Full markdown renderer: GFM (tables, task lists, strikethrough), math (KaTeX),
|
|
50
|
+
* Shiki code blocks, Mermaid diagrams, GitHub-style callouts, heading anchors,
|
|
51
|
+
* and lazy, zoomable images. Requires `katex/dist/katex.min.css` and the YunUI
|
|
52
|
+
* content styles to be imported by the host app.
|
|
53
|
+
*/
|
|
54
|
+
declare function MarkdownRenderer({ content, className, urlTransform, onCodeEdit, }: MarkdownRendererProps): React.JSX.Element;
|
|
55
|
+
|
|
56
|
+
type CalloutType = "note" | "tip" | "important" | "warning" | "caution" | "success";
|
|
57
|
+
interface CalloutBlockProps {
|
|
58
|
+
type: CalloutType;
|
|
59
|
+
title?: string;
|
|
60
|
+
children: React.ReactNode;
|
|
61
|
+
className?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Callout box (note / tip / important / warning / caution / success). Composes
|
|
65
|
+
* YunUI's `Alert` primitive, so it shares the exact soft-tint panel, all-side
|
|
66
|
+
* soft border, leading semantic icon and title of every other Alert in the
|
|
67
|
+
* system — the callout is literally an Alert, not a re-implementation.
|
|
68
|
+
*/
|
|
69
|
+
declare function CalloutBlock({ type, title, children, className, }: CalloutBlockProps): React.JSX.Element;
|
|
70
|
+
/**
|
|
71
|
+
* Parse a GitHub-style callout marker (`[!NOTE] optional title`) from the first
|
|
72
|
+
* line of a blockquote. Returns `{ type: null }` when the line isn't a callout.
|
|
73
|
+
*/
|
|
74
|
+
declare function parseCalloutType(text: string): {
|
|
75
|
+
type: CalloutType | null;
|
|
76
|
+
title: string | null;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
interface MathRendererProps {
|
|
80
|
+
math: string;
|
|
81
|
+
block?: boolean;
|
|
82
|
+
className?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Render a LaTeX expression with KaTeX. Requires `katex/dist/katex.min.css` to
|
|
86
|
+
* be imported by the host app.
|
|
87
|
+
*/
|
|
88
|
+
declare function MathRenderer({ math, block, className }: MathRendererProps): React.JSX.Element;
|
|
89
|
+
/** Inline math (`$…$`) — used by the markdown renderer's math plugin. */
|
|
90
|
+
declare function InlineMath({ value }: {
|
|
91
|
+
value: string;
|
|
92
|
+
}): React.JSX.Element;
|
|
93
|
+
/** Block/display math (`$$…$$`) — used by the markdown renderer's math plugin. */
|
|
94
|
+
declare function BlockMath({ value }: {
|
|
95
|
+
value: string;
|
|
96
|
+
}): React.JSX.Element;
|
|
97
|
+
|
|
98
|
+
interface MermaidDiagramProps {
|
|
99
|
+
chart: string;
|
|
100
|
+
className?: string;
|
|
101
|
+
/** Click the diagram to open a full-screen zoomable view. @defaultValue true */
|
|
102
|
+
enableZoom?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Render a Mermaid diagram (flowchart, sequence, gantt, …). The `mermaid`
|
|
106
|
+
* library is loaded on demand the first time a diagram renders, so it never
|
|
107
|
+
* ships in the initial bundle. Re-themes automatically for light/dark.
|
|
108
|
+
*/
|
|
109
|
+
declare function MermaidDiagram({ chart, className, enableZoom, }: MermaidDiagramProps): React.JSX.Element;
|
|
110
|
+
|
|
111
|
+
interface ImageLightboxProps {
|
|
112
|
+
/** Image URL to view. Omit when providing custom `children` (e.g. an SVG). */
|
|
113
|
+
src?: string;
|
|
114
|
+
alt?: string;
|
|
115
|
+
isOpen: boolean;
|
|
116
|
+
onClose: () => void;
|
|
117
|
+
/**
|
|
118
|
+
* Custom zoomable content instead of an `<img src>` — e.g. an inline SVG
|
|
119
|
+
* diagram. Download is only offered when `src` is set.
|
|
120
|
+
*/
|
|
121
|
+
children?: React.ReactNode;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Full-screen viewer with zoom, rotate, download and keyboard shortcuts
|
|
125
|
+
* (Esc / +/- / R). Views an image (`src`) or any custom `children` (e.g. an
|
|
126
|
+
* inline SVG diagram). Rendered into a portal on `document.body`.
|
|
127
|
+
*/
|
|
128
|
+
declare function ImageLightbox({ src, alt, isOpen, onClose, children }: ImageLightboxProps): React.ReactPortal | null;
|
|
129
|
+
|
|
130
|
+
interface ContentImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
131
|
+
/** Open a zoom/rotate/download lightbox on click. @defaultValue true */
|
|
132
|
+
enableLightbox?: boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Lazy, flicker-free image for rendered content. Defers loading until the image
|
|
136
|
+
* scrolls near the viewport (IntersectionObserver), fades in on load, shows a
|
|
137
|
+
* spinner placeholder, and (by default) opens a full-screen lightbox on click.
|
|
138
|
+
*
|
|
139
|
+
* URLs are used as-is — resolve/rewrite them upstream (e.g. via the markdown
|
|
140
|
+
* renderer's `urlTransform`).
|
|
141
|
+
*/
|
|
142
|
+
declare const ContentImage: React.MemoExoticComponent<({ enableLightbox, className, alt, src, onError, onLoad, ...rest }: ContentImageProps) => React.JSX.Element | null>;
|
|
143
|
+
|
|
144
|
+
export { BlockMath, CalloutBlock, type CalloutBlockProps, type CalloutType, CodeBlock, type CodeBlockEditPayload, type CodeBlockProps, ContentImage, type ContentImageProps, ImageLightbox, type ImageLightboxProps, InlineCode, InlineMath, MarkdownRenderer, type MarkdownRendererProps, MathRenderer, type MathRendererProps, MermaidDiagram, type MermaidDiagramProps, parseCalloutType };
|