@agentaily/design-system 0.6.0 → 0.7.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/DESIGN.md +2 -2
- package/README.md +2 -2
- package/dist/components/chat/Markdown.d.ts +30 -0
- package/dist/components/chat/Markdown.js +502 -0
- package/dist/components/chat/Markdown.js.map +1 -0
- package/dist/components/chat/Message.d.ts +6 -0
- package/dist/components/chat/Message.js +11 -1
- package/dist/components/chat/Message.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/DESIGN.md
CHANGED
|
@@ -93,7 +93,7 @@ Examples — ✓ "Rate limited. Retry in 18s." ✗ "Oops! Something went wrong
|
|
|
93
93
|
| `components/feedback/` | Spinner, Toast, Tooltip, Dialog, Alert |
|
|
94
94
|
| `components/overlay/` | Popover, DropdownMenu, Command, Sheet, **HoverCard, ContextMenu, Menubar, NavigationMenu, AlertDialog** |
|
|
95
95
|
| `components/layout/` | **AspectRatio, ScrollArea, Resizable, Sidebar, AppShell, DesignerShell, DocsLayout, SettingsPage** — incl. full-page shells/frames |
|
|
96
|
-
| `components/chat/` | Message, Composer, CodeBlock, **ConversationThread** |
|
|
96
|
+
| `components/chat/` | Message, Composer, CodeBlock, **ConversationThread, Markdown** |
|
|
97
97
|
| `components/ai/` | Reasoning, ToolCall, Sources + Citation, Suggestion/Suggestions, ModelSelector, Attachments, Shimmer, **Conversation, Task, Plan, Context, Confirmation, Checkpoint, Queue** |
|
|
98
98
|
| `components/code/` | **Terminal, FileTree, Snippet, StackTrace, TestResults, Artifact, WebPreview, Agent, Commit, EnvironmentVariables, PackageInfo, Sandbox, SchemaDisplay, JSXPreview** |
|
|
99
99
|
| `components/voice/` | **AudioPlayer, MicSelector, VoiceSelector, SpeechInput, Transcription, Persona** |
|
|
@@ -108,7 +108,7 @@ Examples — ✓ "Rate limited. Retry in 18s." ✗ "Oops! Something went wrong
|
|
|
108
108
|
| `ui_kits/docs/` | Documentation site (interactive) |
|
|
109
109
|
| `SKILL.md` | Agent-skill entry point |
|
|
110
110
|
|
|
111
|
-
Every component ships `<Name>.jsx` + `<Name>.d.ts` (props) + `<Name>.prompt.md` (usage) — **
|
|
111
|
+
Every component ships `<Name>.jsx` + `<Name>.d.ts` (props) + `<Name>.prompt.md` (usage) — **148 component exports** across the primitive categories (buttons, inputs, display, feedback, overlay, layout, chat, ai, code, voice, workflow, utilities) plus product-domain layers (**settings, auth, review**). Full-page frames — `AppShell` / `DesignerShell` / `DocsLayout` / `SettingsPage` (layout), `ConversationThread` (chat), `SignInPage` (auth) — are **live components, not copy-templates**: change one, every consuming project benefits on re-sync. Consume via the compiled bundle: `window.AxiomDesignSystem_7fc962`. Read each component's `.prompt.md` for copy-paste usage.
|
|
112
112
|
|
|
113
113
|
**Forms are layered, not monolithic.** Presentational controls (Input/Select/Field…) own layout and never depend on a form engine. `Form` + `FormActions` add pure structure. `Form.useForm` is an **optional**, zero-dependency orchestration hook (values/errors/touched/validate/submit) exposed off the capitalized `Form` export — drop it for react-hook-form or TanStack and the controls still work. Errors surface only after blur or submit; spread `form.field(name)` onto any value control, or `form.field(name, {type:"checkbox"})` for boolean ones.
|
|
114
114
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# agentaily design system
|
|
2
2
|
|
|
3
|
-
Agentaily(AI chatbot)设计系统:
|
|
3
|
+
Agentaily(AI chatbot)设计系统:115 个 React 组件 + Storybook,单色亮色优先(暗色可切)。品牌一句话:**极客风格,简约,大气,科技感**。
|
|
4
4
|
|
|
5
5
|
📖 **在线 Storybook:** https://agentaily.github.io/design-system/
|
|
6
6
|
|
|
@@ -28,7 +28,7 @@ npm run build:lib # 产出 dist/:每组件一个 .js + index.d.ts + styles.css
|
|
|
28
28
|
|
|
29
29
|
| 路径 | 内容 |
|
|
30
30
|
| ----------------------------------------------- | ----------------------------------------- |
|
|
31
|
-
| `dist/index.js` | ESM 入口,re-export 全部
|
|
31
|
+
| `dist/index.js` | ESM 入口,re-export 全部 115 个组件符号 |
|
|
32
32
|
| `dist/components/**/*.js` | 每个组件独立模块(含运行时 CSS 注入) |
|
|
33
33
|
| `dist/index.d.ts` + `dist/components/**/*.d.ts` | TypeScript 类型契约 |
|
|
34
34
|
| `dist/styles.css` | 内联好的 tokens + 字体,消费方 import 一次 |
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a model's markdown STRING into typeset, theme-aware React nodes.
|
|
3
|
+
*
|
|
4
|
+
* Composable primitive for any surface that shows model output. `<Message>`
|
|
5
|
+
* uses it internally to render assistant prose, but it stands alone too.
|
|
6
|
+
*
|
|
7
|
+
* Coverage: paragraphs + soft line breaks, **bold**, *italic*, ~~strikethrough~~,
|
|
8
|
+
* `inline code`, fenced ```code blocks``` (rendered via <CodeBlock>), unordered +
|
|
9
|
+
* ordered + nested (mixed) lists, GitHub task lists (- [ ] / - [x]), blockquotes
|
|
10
|
+
* (nested), GFM tables with per-column alignment (overflow scrolls), horizontal
|
|
11
|
+
* rules (--- / *** / ___), #/##/### headings, [links](url), and bare-URL autolinks.
|
|
12
|
+
* Images  render as an inert placeholder chip — never fetched.
|
|
13
|
+
*
|
|
14
|
+
* Safety: the string is parsed to a node tree and emitted as React elements
|
|
15
|
+
* only — never dangerouslySetInnerHTML — so all literal text is auto-escaped
|
|
16
|
+
* and there is no HTML-injection surface. Link hrefs are scheme-sanitized
|
|
17
|
+
* (javascript:/data:/vbscript: are dropped); images are not loaded.
|
|
18
|
+
*
|
|
19
|
+
* Streaming: unterminated inline delimiters (** ` _ ~~ [..]( ) degrade to literal
|
|
20
|
+
* text; a half table, a half blockquote, and an unclosed ``` fence render their
|
|
21
|
+
* partial content, so a half-streamed token never throws or vanishes mid-stream.
|
|
22
|
+
*/
|
|
23
|
+
export interface MarkdownProps {
|
|
24
|
+
/** The markdown source string. Takes precedence over a string `children`. */
|
|
25
|
+
content?: string;
|
|
26
|
+
/** Alternative to `content`: a markdown string passed as children. */
|
|
27
|
+
children?: string;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function Markdown(props: MarkdownProps): JSX.Element;
|
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CodeBlock } from "./CodeBlock.js";
|
|
4
|
+
const AX_MD_CSS = `
|
|
5
|
+
.ax-md { font-size: var(--text-md); line-height: var(--leading-body); color: var(--text-body); min-width: 0; }
|
|
6
|
+
.ax-md > :first-child { margin-top: 0; }
|
|
7
|
+
.ax-md > :last-child { margin-bottom: 0; }
|
|
8
|
+
|
|
9
|
+
.ax-md__p { margin: 0 0 0.7em; text-wrap: pretty; }
|
|
10
|
+
|
|
11
|
+
.ax-md__ul, .ax-md__ol { margin: 0 0 0.7em; padding-left: 1.5em; }
|
|
12
|
+
.ax-md__li { margin: 0.2em 0; }
|
|
13
|
+
.ax-md__li > .ax-md__ul, .ax-md__li > .ax-md__ol { margin: 0.25em 0 0; padding-left: 1.3em; }
|
|
14
|
+
|
|
15
|
+
.ax-md__ul { list-style: none; padding-left: 1.35em; }
|
|
16
|
+
.ax-md__ul > .ax-md__li { position: relative; }
|
|
17
|
+
.ax-md__ul > .ax-md__li::before {
|
|
18
|
+
content: ""; position: absolute; left: -1.05em; top: 0.62em;
|
|
19
|
+
width: 4px; height: 4px; background: var(--text-faint);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.ax-md__ol { list-style: decimal; padding-left: 1.7em; }
|
|
23
|
+
.ax-md__ol > .ax-md__li::marker {
|
|
24
|
+
font-family: var(--font-mono); font-size: 0.9em; color: var(--text-faint);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ax-md__li--task { list-style: none; display: flex; align-items: flex-start; gap: 8px; }
|
|
28
|
+
.ax-md__ul > .ax-md__li--task::before { display: none; }
|
|
29
|
+
.ax-md__check {
|
|
30
|
+
appearance: none; -webkit-appearance: none; margin: 3px 0 0; flex: none;
|
|
31
|
+
width: 15px; height: 15px; border: 1px solid var(--border-strong);
|
|
32
|
+
border-radius: var(--radius-1); background: var(--bg-0); position: relative; cursor: default;
|
|
33
|
+
}
|
|
34
|
+
.ax-md__check:checked { background: var(--accent); border-color: var(--accent); }
|
|
35
|
+
.ax-md__check:checked::after {
|
|
36
|
+
content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
|
|
37
|
+
border: solid var(--accent-fg); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg);
|
|
38
|
+
}
|
|
39
|
+
.ax-md__li--task > .ax-md__taskbody { flex: 1; min-width: 0; }
|
|
40
|
+
|
|
41
|
+
.ax-md__strong { font-weight: var(--weight-bold); color: var(--text-body); }
|
|
42
|
+
.ax-md__em { font-style: italic; }
|
|
43
|
+
.ax-md__del { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--text-muted); }
|
|
44
|
+
|
|
45
|
+
.ax-md__code {
|
|
46
|
+
font-family: var(--font-mono); font-size: 0.86em;
|
|
47
|
+
background: var(--bg-3); color: var(--text-body);
|
|
48
|
+
border: 1px solid var(--border-default);
|
|
49
|
+
border-radius: var(--radius-1); padding: 0.12em 0.36em;
|
|
50
|
+
white-space: break-spaces; word-break: break-word;
|
|
51
|
+
}
|
|
52
|
+
[data-theme="dark"] .ax-md__code { background: var(--bg-2); }
|
|
53
|
+
|
|
54
|
+
.ax-md > .ax-code, .ax-md__li > .ax-code, .ax-md__quote > .ax-code { margin: 0 0 0.7em; }
|
|
55
|
+
|
|
56
|
+
.ax-md__link {
|
|
57
|
+
color: var(--text-body); text-decoration: underline;
|
|
58
|
+
text-underline-offset: 2px; text-decoration-color: var(--border-strong);
|
|
59
|
+
transition: text-decoration-color var(--dur-1) var(--ease-out);
|
|
60
|
+
word-break: break-word;
|
|
61
|
+
}
|
|
62
|
+
.ax-md__link:hover { text-decoration-color: var(--text-body); }
|
|
63
|
+
|
|
64
|
+
.ax-md__img {
|
|
65
|
+
display: inline-flex; align-items: center; gap: 6px; vertical-align: baseline;
|
|
66
|
+
padding: 1px 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-1);
|
|
67
|
+
font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-faint);
|
|
68
|
+
}
|
|
69
|
+
.ax-md__img b { font-weight: var(--weight-medium); letter-spacing: var(--tracking-label); }
|
|
70
|
+
|
|
71
|
+
.ax-md__quote {
|
|
72
|
+
margin: 0 0 0.7em; padding: 2px 0 2px 14px;
|
|
73
|
+
border-left: 2px solid var(--border-strong); color: var(--text-muted);
|
|
74
|
+
}
|
|
75
|
+
.ax-md__quote > :last-child { margin-bottom: 0; }
|
|
76
|
+
.ax-md__quote .ax-md__quote { margin-top: 0.5em; }
|
|
77
|
+
|
|
78
|
+
.ax-md__hr { border: none; border-top: 1px solid var(--border-default); margin: 1.2em 0; }
|
|
79
|
+
|
|
80
|
+
.ax-md__tablewrap {
|
|
81
|
+
margin: 0 0 0.7em; overflow-x: auto;
|
|
82
|
+
border: 1px solid var(--border-default); border-radius: var(--radius-2);
|
|
83
|
+
}
|
|
84
|
+
.ax-md__table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
|
|
85
|
+
.ax-md__table th, .ax-md__table td {
|
|
86
|
+
padding: 7px 12px; text-align: left; vertical-align: top;
|
|
87
|
+
border-bottom: 1px solid var(--border-default); border-right: 1px solid var(--border-default);
|
|
88
|
+
}
|
|
89
|
+
.ax-md__table th:last-child, .ax-md__table td:last-child { border-right: none; }
|
|
90
|
+
.ax-md__table tbody tr:last-child td { border-bottom: none; }
|
|
91
|
+
.ax-md__table thead th {
|
|
92
|
+
background: var(--surface-card); color: var(--text-body);
|
|
93
|
+
font-weight: var(--weight-medium); white-space: nowrap;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.ax-md__h { font-family: var(--font-display); font-weight: var(--weight-medium);
|
|
97
|
+
line-height: var(--leading-snug); letter-spacing: var(--tracking-tight);
|
|
98
|
+
margin: 1.1em 0 0.5em; color: var(--text-body); }
|
|
99
|
+
.ax-md__h--1 { font-size: var(--text-xl); }
|
|
100
|
+
.ax-md__h--2 { font-size: var(--text-lg); }
|
|
101
|
+
.ax-md__h--3 { font-size: var(--text-md); }
|
|
102
|
+
`;
|
|
103
|
+
if (typeof document !== "undefined" && !document.getElementById("ax-md-css")) {
|
|
104
|
+
const s = document.createElement("style");
|
|
105
|
+
s.id = "ax-md-css";
|
|
106
|
+
s.textContent = AX_MD_CSS;
|
|
107
|
+
document.head.appendChild(s);
|
|
108
|
+
}
|
|
109
|
+
function sanitizeUrl(raw) {
|
|
110
|
+
const url = String(raw || "").replace(/[\u0000-\u001F\u007F]/g, "").trim();
|
|
111
|
+
if (!url) return null;
|
|
112
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {
|
|
113
|
+
if (/^(https?|mailto|tel):/i.test(url)) return url;
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return url;
|
|
117
|
+
}
|
|
118
|
+
function parseInline(text, keyBase) {
|
|
119
|
+
const out = [];
|
|
120
|
+
let buf = "";
|
|
121
|
+
let i = 0;
|
|
122
|
+
let k = 0;
|
|
123
|
+
const len = text.length;
|
|
124
|
+
const flush = () => {
|
|
125
|
+
if (buf) {
|
|
126
|
+
out.push(buf);
|
|
127
|
+
buf = "";
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
while (i < len) {
|
|
131
|
+
const ch = text[i];
|
|
132
|
+
const rest = text.slice(i);
|
|
133
|
+
if (ch === "\n") {
|
|
134
|
+
flush();
|
|
135
|
+
out.push(/* @__PURE__ */ jsx("br", {}, keyBase + "-br" + k++));
|
|
136
|
+
i++;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (ch === "\\" && i + 1 < len && /[\\`*_{}\[\]()#+\-.!~|>]/.test(text[i + 1])) {
|
|
140
|
+
buf += text[i + 1];
|
|
141
|
+
i += 2;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
let m;
|
|
145
|
+
if (ch === "`" && (m = /^`([^`\n]+?)`/.exec(rest))) {
|
|
146
|
+
flush();
|
|
147
|
+
out.push(
|
|
148
|
+
/* @__PURE__ */ jsx("code", { className: "ax-md__code", children: m[1] }, keyBase + "-c" + k++)
|
|
149
|
+
);
|
|
150
|
+
i += m[0].length;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (ch === "!" && text[i + 1] === "[" && (m = /^!\[([^\]]*)\]\(([^)\s]*)\)/.exec(rest))) {
|
|
154
|
+
flush();
|
|
155
|
+
out.push(
|
|
156
|
+
/* @__PURE__ */ jsxs("span", { className: "ax-md__img", title: m[2], children: [
|
|
157
|
+
/* @__PURE__ */ jsx("b", { children: "IMG" }),
|
|
158
|
+
m[1] ? " · " + m[1] : ""
|
|
159
|
+
] }, keyBase + "-img" + k++)
|
|
160
|
+
);
|
|
161
|
+
i += m[0].length;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (ch === "[" && (m = /^\[([^\]]*)\]\(([^)\s]*)\)/.exec(rest))) {
|
|
165
|
+
flush();
|
|
166
|
+
const href = sanitizeUrl(m[2]);
|
|
167
|
+
const inner = parseInline(m[1], keyBase + "-lt" + k);
|
|
168
|
+
out.push(
|
|
169
|
+
href ? /* @__PURE__ */ jsx(
|
|
170
|
+
"a",
|
|
171
|
+
{
|
|
172
|
+
className: "ax-md__link",
|
|
173
|
+
href,
|
|
174
|
+
target: "_blank",
|
|
175
|
+
rel: "noopener noreferrer nofollow",
|
|
176
|
+
children: inner
|
|
177
|
+
},
|
|
178
|
+
keyBase + "-l" + k++
|
|
179
|
+
) : /* @__PURE__ */ jsx("span", { children: inner }, keyBase + "-l" + k++)
|
|
180
|
+
);
|
|
181
|
+
i += m[0].length;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if ((ch === "h" || ch === "w") && (i === 0 || /[\s(]/.test(text[i - 1])) && (m = /^((?:https?:\/\/|www\.)[^\s<>]+)/i.exec(rest))) {
|
|
185
|
+
let urlText = m[1];
|
|
186
|
+
const trail = /[.,;:!?'")\]]+$/.exec(urlText);
|
|
187
|
+
if (trail) urlText = urlText.slice(0, urlText.length - trail[0].length);
|
|
188
|
+
const href = sanitizeUrl(/^www\./i.test(urlText) ? "http://" + urlText : urlText);
|
|
189
|
+
if (href) {
|
|
190
|
+
flush();
|
|
191
|
+
out.push(
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
"a",
|
|
194
|
+
{
|
|
195
|
+
className: "ax-md__link",
|
|
196
|
+
href,
|
|
197
|
+
target: "_blank",
|
|
198
|
+
rel: "noopener noreferrer nofollow",
|
|
199
|
+
children: urlText
|
|
200
|
+
},
|
|
201
|
+
keyBase + "-a" + k++
|
|
202
|
+
)
|
|
203
|
+
);
|
|
204
|
+
i += urlText.length;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (ch === "*" && (m = /^\*\*([\s\S]+?)\*\*/.exec(rest))) {
|
|
209
|
+
flush();
|
|
210
|
+
out.push(
|
|
211
|
+
/* @__PURE__ */ jsx("strong", { className: "ax-md__strong", children: parseInline(m[1], keyBase + "-bt" + k) }, keyBase + "-b" + k++)
|
|
212
|
+
);
|
|
213
|
+
i += m[0].length;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (ch === "_" && (m = /^__([\s\S]+?)__/.exec(rest))) {
|
|
217
|
+
flush();
|
|
218
|
+
out.push(
|
|
219
|
+
/* @__PURE__ */ jsx("strong", { className: "ax-md__strong", children: parseInline(m[1], keyBase + "-bt" + k) }, keyBase + "-b" + k++)
|
|
220
|
+
);
|
|
221
|
+
i += m[0].length;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (ch === "~" && (m = /^~~([\s\S]+?)~~/.exec(rest))) {
|
|
225
|
+
flush();
|
|
226
|
+
out.push(
|
|
227
|
+
/* @__PURE__ */ jsx("del", { className: "ax-md__del", children: parseInline(m[1], keyBase + "-st" + k) }, keyBase + "-s" + k++)
|
|
228
|
+
);
|
|
229
|
+
i += m[0].length;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (ch === "*" && (m = new RegExp("^\\*(?!\\s)([^*]+?)(?<!\\s)\\*").exec(rest))) {
|
|
233
|
+
flush();
|
|
234
|
+
out.push(
|
|
235
|
+
/* @__PURE__ */ jsx("em", { className: "ax-md__em", children: parseInline(m[1], keyBase + "-it" + k) }, keyBase + "-i" + k++)
|
|
236
|
+
);
|
|
237
|
+
i += m[0].length;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (ch === "_" && (m = new RegExp("^_(?!\\s)([^_]+?)(?<!\\s)_").exec(rest))) {
|
|
241
|
+
flush();
|
|
242
|
+
out.push(
|
|
243
|
+
/* @__PURE__ */ jsx("em", { className: "ax-md__em", children: parseInline(m[1], keyBase + "-it" + k) }, keyBase + "-i" + k++)
|
|
244
|
+
);
|
|
245
|
+
i += m[0].length;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
buf += ch;
|
|
249
|
+
i++;
|
|
250
|
+
}
|
|
251
|
+
flush();
|
|
252
|
+
return out;
|
|
253
|
+
}
|
|
254
|
+
const RE_FENCE = /^(\s{0,3})(`{3,}|~{3,})\s*([\w+#.-]*)\s*$/;
|
|
255
|
+
const RE_HEADING = /^(#{1,6})\s+(.*)$/;
|
|
256
|
+
const RE_HR = /^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/;
|
|
257
|
+
const RE_BLANK = /^\s*$/;
|
|
258
|
+
const RE_QUOTE = /^\s*>/;
|
|
259
|
+
const RE_LIST_ITEM = /^([ \t]*)([-*+]|\d{1,9}[.)])\s+(.*)$/;
|
|
260
|
+
function leadingSpaces(s) {
|
|
261
|
+
const m = /^[ \t]*/.exec(s);
|
|
262
|
+
return m[0].length;
|
|
263
|
+
}
|
|
264
|
+
function listMarkerInfo(line) {
|
|
265
|
+
const m = RE_LIST_ITEM.exec(line);
|
|
266
|
+
if (!m) return null;
|
|
267
|
+
const ordered = /\d/.test(m[2]);
|
|
268
|
+
return {
|
|
269
|
+
indent: m[1].length,
|
|
270
|
+
bullet: ordered ? "ol" : "ul",
|
|
271
|
+
start: ordered ? parseInt(m[2], 10) : null,
|
|
272
|
+
text: m[3],
|
|
273
|
+
raw: m[0]
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function splitTableRow(row) {
|
|
277
|
+
let s = row.trim();
|
|
278
|
+
if (s.startsWith("|")) s = s.slice(1);
|
|
279
|
+
if (s.endsWith("|")) s = s.slice(0, -1);
|
|
280
|
+
return s.split(new RegExp("(?<!\\\\)\\|")).map((c) => c.trim().replace(/\\\|/g, "|"));
|
|
281
|
+
}
|
|
282
|
+
function isTableSep(line) {
|
|
283
|
+
if (!line.includes("|")) return false;
|
|
284
|
+
const cells = splitTableRow(line);
|
|
285
|
+
return cells.length > 0 && cells.every((c) => /^:?-{1,}:?$/.test(c.trim()));
|
|
286
|
+
}
|
|
287
|
+
function alignOf(cell) {
|
|
288
|
+
const c = cell.trim();
|
|
289
|
+
const l = c.startsWith(":"), r = c.endsWith(":");
|
|
290
|
+
if (l && r) return "center";
|
|
291
|
+
if (r) return "right";
|
|
292
|
+
if (l) return "left";
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
function startsBlock(lines, i) {
|
|
296
|
+
const line = lines[i];
|
|
297
|
+
if (RE_FENCE.test(line)) return true;
|
|
298
|
+
if (RE_HR.test(line)) return true;
|
|
299
|
+
if (RE_HEADING.test(line)) return true;
|
|
300
|
+
if (RE_QUOTE.test(line)) return true;
|
|
301
|
+
if (listMarkerInfo(line)) return true;
|
|
302
|
+
if (line.includes("|") && i + 1 < lines.length && isTableSep(lines[i + 1])) return true;
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
function parseList(lines, i) {
|
|
306
|
+
const base = leadingSpaces(lines[i]);
|
|
307
|
+
const baseInfo = listMarkerInfo(lines[i]);
|
|
308
|
+
const type = baseInfo.bullet;
|
|
309
|
+
const start = baseInfo.start;
|
|
310
|
+
const items = [];
|
|
311
|
+
while (i < lines.length) {
|
|
312
|
+
if (RE_BLANK.test(lines[i])) {
|
|
313
|
+
let j = i;
|
|
314
|
+
while (j < lines.length && RE_BLANK.test(lines[j])) j++;
|
|
315
|
+
const info2 = j < lines.length ? listMarkerInfo(lines[j]) : null;
|
|
316
|
+
if (j < lines.length && (info2 && leadingSpaces(lines[j]) === base || leadingSpaces(lines[j]) > base)) {
|
|
317
|
+
i = j;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
const ind = leadingSpaces(lines[i]);
|
|
323
|
+
const info = listMarkerInfo(lines[i]);
|
|
324
|
+
if (info && ind === base && info.bullet === type) {
|
|
325
|
+
const markerWidth = info.raw.length - info.text.length;
|
|
326
|
+
const itemLines = [info.text];
|
|
327
|
+
i++;
|
|
328
|
+
while (i < lines.length) {
|
|
329
|
+
if (RE_BLANK.test(lines[i])) {
|
|
330
|
+
let j = i;
|
|
331
|
+
while (j < lines.length && RE_BLANK.test(lines[j])) j++;
|
|
332
|
+
if (j < lines.length && leadingSpaces(lines[j]) > base) {
|
|
333
|
+
itemLines.push("");
|
|
334
|
+
i++;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
if (leadingSpaces(lines[i]) > base) {
|
|
340
|
+
itemLines.push(lines[i].slice(Math.min(markerWidth, leadingSpaces(lines[i]))));
|
|
341
|
+
i++;
|
|
342
|
+
} else break;
|
|
343
|
+
}
|
|
344
|
+
while (itemLines.length && itemLines[itemLines.length - 1] === "") itemLines.pop();
|
|
345
|
+
let checked = null;
|
|
346
|
+
const tm = /^\[([ xX])\]\s+([\s\S]*)$/.exec(itemLines[0] || "");
|
|
347
|
+
if (tm) {
|
|
348
|
+
checked = tm[1].toLowerCase() === "x";
|
|
349
|
+
itemLines[0] = tm[2];
|
|
350
|
+
}
|
|
351
|
+
items.push({ checked, blocks: parseBlocks(itemLines.join("\n")) });
|
|
352
|
+
} else {
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return { type, start, items, next: i };
|
|
357
|
+
}
|
|
358
|
+
function parseBlocks(src) {
|
|
359
|
+
const lines = String(src || "").replace(/\r\n?/g, "\n").split("\n");
|
|
360
|
+
const blocks = [];
|
|
361
|
+
let i = 0;
|
|
362
|
+
while (i < lines.length) {
|
|
363
|
+
const line = lines[i];
|
|
364
|
+
const fence = RE_FENCE.exec(line);
|
|
365
|
+
if (fence) {
|
|
366
|
+
const mark = fence[2][0];
|
|
367
|
+
const len = fence[2].length;
|
|
368
|
+
const close = new RegExp("^\\s{0,3}" + mark + "{" + len + ",}\\s*$");
|
|
369
|
+
i++;
|
|
370
|
+
const code = [];
|
|
371
|
+
while (i < lines.length && !close.test(lines[i])) {
|
|
372
|
+
code.push(lines[i]);
|
|
373
|
+
i++;
|
|
374
|
+
}
|
|
375
|
+
if (i < lines.length) i++;
|
|
376
|
+
blocks.push({ type: "code", lang: fence[3] || "", code: code.join("\n") });
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
if (RE_BLANK.test(line)) {
|
|
380
|
+
i++;
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (RE_HR.test(line)) {
|
|
384
|
+
blocks.push({ type: "hr" });
|
|
385
|
+
i++;
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
const h = RE_HEADING.exec(line);
|
|
389
|
+
if (h) {
|
|
390
|
+
blocks.push({ type: "heading", level: h[1].length, text: h[2] });
|
|
391
|
+
i++;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (RE_QUOTE.test(line)) {
|
|
395
|
+
const inner = [];
|
|
396
|
+
while (i < lines.length && RE_QUOTE.test(lines[i])) {
|
|
397
|
+
inner.push(lines[i].replace(/^\s*>\s?/, ""));
|
|
398
|
+
i++;
|
|
399
|
+
}
|
|
400
|
+
blocks.push({ type: "quote", blocks: parseBlocks(inner.join("\n")) });
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
if (line.includes("|") && i + 1 < lines.length && isTableSep(lines[i + 1])) {
|
|
404
|
+
const header = splitTableRow(line);
|
|
405
|
+
const aligns = splitTableRow(lines[i + 1]).map(alignOf);
|
|
406
|
+
i += 2;
|
|
407
|
+
const rows = [];
|
|
408
|
+
while (i < lines.length && !RE_BLANK.test(lines[i]) && lines[i].includes("|") && !RE_FENCE.test(lines[i]) && !RE_QUOTE.test(lines[i])) {
|
|
409
|
+
rows.push(splitTableRow(lines[i]));
|
|
410
|
+
i++;
|
|
411
|
+
}
|
|
412
|
+
blocks.push({ type: "table", header, aligns, rows });
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
if (listMarkerInfo(line)) {
|
|
416
|
+
const res = parseList(lines, i);
|
|
417
|
+
blocks.push({ type: "list", listType: res.type, start: res.start, items: res.items });
|
|
418
|
+
i = res.next;
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
const para = [line];
|
|
422
|
+
i++;
|
|
423
|
+
while (i < lines.length && !RE_BLANK.test(lines[i]) && !startsBlock(lines, i)) {
|
|
424
|
+
para.push(lines[i]);
|
|
425
|
+
i++;
|
|
426
|
+
}
|
|
427
|
+
blocks.push({ type: "p", text: para.join("\n") });
|
|
428
|
+
}
|
|
429
|
+
return blocks;
|
|
430
|
+
}
|
|
431
|
+
function renderItemContent(blocks, key) {
|
|
432
|
+
if (blocks.length === 1 && blocks[0].type === "p") return parseInline(blocks[0].text, key);
|
|
433
|
+
return blocks.map(
|
|
434
|
+
(b, j) => b.type === "p" ? /* @__PURE__ */ jsx(React.Fragment, { children: parseInline(b.text, key + "-" + j) }, j) : renderBlock(b, key + "-" + j)
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
function renderList(b, key) {
|
|
438
|
+
const Tag = b.listType === "ol" ? "ol" : "ul";
|
|
439
|
+
const cls = b.listType === "ol" ? "ax-md__ol" : "ax-md__ul";
|
|
440
|
+
const startAttr = b.listType === "ol" && b.start && b.start !== 1 ? b.start : void 0;
|
|
441
|
+
return /* @__PURE__ */ jsx(Tag, { className: cls, start: startAttr, children: b.items.map((it, j) => {
|
|
442
|
+
const content = renderItemContent(it.blocks, key + "-" + j);
|
|
443
|
+
if (it.checked !== null) {
|
|
444
|
+
return /* @__PURE__ */ jsxs("li", { className: "ax-md__li ax-md__li--task", children: [
|
|
445
|
+
/* @__PURE__ */ jsx(
|
|
446
|
+
"input",
|
|
447
|
+
{
|
|
448
|
+
type: "checkbox",
|
|
449
|
+
className: "ax-md__check",
|
|
450
|
+
checked: it.checked,
|
|
451
|
+
disabled: true,
|
|
452
|
+
readOnly: true
|
|
453
|
+
}
|
|
454
|
+
),
|
|
455
|
+
/* @__PURE__ */ jsx("span", { className: "ax-md__taskbody", children: content })
|
|
456
|
+
] }, j);
|
|
457
|
+
}
|
|
458
|
+
return /* @__PURE__ */ jsx("li", { className: "ax-md__li", children: content }, j);
|
|
459
|
+
}) }, key);
|
|
460
|
+
}
|
|
461
|
+
function renderTable(b, key) {
|
|
462
|
+
const cols = b.header.length;
|
|
463
|
+
return /* @__PURE__ */ jsx("div", { className: "ax-md__tablewrap", children: /* @__PURE__ */ jsxs("table", { className: "ax-md__table", children: [
|
|
464
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: b.header.map((c, ci) => /* @__PURE__ */ jsx("th", { style: { textAlign: b.aligns[ci] || "left" }, children: parseInline(c, key + "-h" + ci) }, ci)) }) }),
|
|
465
|
+
/* @__PURE__ */ jsx("tbody", { children: b.rows.map((r, ri) => /* @__PURE__ */ jsx("tr", { children: Array.from({ length: cols }).map((_, ci) => /* @__PURE__ */ jsx("td", { style: { textAlign: b.aligns[ci] || "left" }, children: parseInline(r[ci] || "", key + "-r" + ri + "c" + ci) }, ci)) }, ri)) })
|
|
466
|
+
] }) }, key);
|
|
467
|
+
}
|
|
468
|
+
function renderBlock(b, key) {
|
|
469
|
+
switch (b.type) {
|
|
470
|
+
case "code":
|
|
471
|
+
return /* @__PURE__ */ jsx(CodeBlock, { code: b.code, lang: b.lang || "text" }, key);
|
|
472
|
+
case "hr":
|
|
473
|
+
return /* @__PURE__ */ jsx("hr", { className: "ax-md__hr" }, key);
|
|
474
|
+
case "quote":
|
|
475
|
+
return /* @__PURE__ */ jsx("blockquote", { className: "ax-md__quote", children: renderBlocks(b.blocks, key) }, key);
|
|
476
|
+
case "table":
|
|
477
|
+
return renderTable(b, key);
|
|
478
|
+
case "list":
|
|
479
|
+
return renderList(b, key);
|
|
480
|
+
case "heading": {
|
|
481
|
+
const lvl = Math.min(b.level, 3);
|
|
482
|
+
const Tag = "h" + Math.min(b.level + 1, 6);
|
|
483
|
+
return /* @__PURE__ */ jsx(Tag, { className: "ax-md__h ax-md__h--" + lvl, children: parseInline(b.text, key) }, key);
|
|
484
|
+
}
|
|
485
|
+
case "p":
|
|
486
|
+
default:
|
|
487
|
+
return /* @__PURE__ */ jsx("p", { className: "ax-md__p", children: parseInline(b.text, key) }, key);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function renderBlocks(blocks, keyBase) {
|
|
491
|
+
return blocks.map((b, idx) => renderBlock(b, keyBase + "-blk" + idx));
|
|
492
|
+
}
|
|
493
|
+
function Markdown({ content, children, className = "", ...rest }) {
|
|
494
|
+
const src = typeof content === "string" ? content : typeof children === "string" ? children : "";
|
|
495
|
+
const blocks = React.useMemo(() => parseBlocks(src), [src]);
|
|
496
|
+
const cls = ["ax-md", className].filter(Boolean).join(" ");
|
|
497
|
+
return /* @__PURE__ */ jsx("div", { className: cls, ...rest, children: renderBlocks(blocks, "md") });
|
|
498
|
+
}
|
|
499
|
+
export {
|
|
500
|
+
Markdown
|
|
501
|
+
};
|
|
502
|
+
//# sourceMappingURL=Markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Markdown.js","sources":["../../../src/components/chat/Markdown.jsx"],"sourcesContent":["import React from \"react\";\nimport { CodeBlock } from \"./CodeBlock.jsx\";\n\n/* ============================================================\n Agentaily — Markdown primitive\n Renders a model's markdown STRING into typeset React nodes.\n\n Safety model: the source string is parsed into a block/inline\n tree and rendered as React elements only. All literal text\n becomes React text nodes (auto-escaped) — we NEVER touch\n dangerouslySetInnerHTML, so there is no HTML-injection surface.\n Link hrefs are scheme-sanitized; images render as inert\n placeholders (no remote fetch).\n\n Streaming model: inline delimiters match only when their\n closing delimiter is present, so an unterminated ** ` _ ~~ or\n [..]( degrades to literal text. A half table, a half blockquote,\n and an unclosed ``` fence all render their partial content\n instead of throwing — nothing disappears mid-stream.\n\n Coverage: paragraphs + soft breaks, bold, italic, strikethrough,\n inline code, code blocks, ordered/unordered/nested/task lists,\n blockquotes (nested), tables (GFM, column alignment), horizontal\n rules, headings, links, bare-URL autolinks, image placeholders.\n ============================================================ */\n\nconst AX_MD_CSS = `\n.ax-md { font-size: var(--text-md); line-height: var(--leading-body); color: var(--text-body); min-width: 0; }\n.ax-md > :first-child { margin-top: 0; }\n.ax-md > :last-child { margin-bottom: 0; }\n\n.ax-md__p { margin: 0 0 0.7em; text-wrap: pretty; }\n\n.ax-md__ul, .ax-md__ol { margin: 0 0 0.7em; padding-left: 1.5em; }\n.ax-md__li { margin: 0.2em 0; }\n.ax-md__li > .ax-md__ul, .ax-md__li > .ax-md__ol { margin: 0.25em 0 0; padding-left: 1.3em; }\n\n.ax-md__ul { list-style: none; padding-left: 1.35em; }\n.ax-md__ul > .ax-md__li { position: relative; }\n.ax-md__ul > .ax-md__li::before {\n content: \"\"; position: absolute; left: -1.05em; top: 0.62em;\n width: 4px; height: 4px; background: var(--text-faint);\n}\n\n.ax-md__ol { list-style: decimal; padding-left: 1.7em; }\n.ax-md__ol > .ax-md__li::marker {\n font-family: var(--font-mono); font-size: 0.9em; color: var(--text-faint);\n}\n\n.ax-md__li--task { list-style: none; display: flex; align-items: flex-start; gap: 8px; }\n.ax-md__ul > .ax-md__li--task::before { display: none; }\n.ax-md__check {\n appearance: none; -webkit-appearance: none; margin: 3px 0 0; flex: none;\n width: 15px; height: 15px; border: 1px solid var(--border-strong);\n border-radius: var(--radius-1); background: var(--bg-0); position: relative; cursor: default;\n}\n.ax-md__check:checked { background: var(--accent); border-color: var(--accent); }\n.ax-md__check:checked::after {\n content: \"\"; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;\n border: solid var(--accent-fg); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg);\n}\n.ax-md__li--task > .ax-md__taskbody { flex: 1; min-width: 0; }\n\n.ax-md__strong { font-weight: var(--weight-bold); color: var(--text-body); }\n.ax-md__em { font-style: italic; }\n.ax-md__del { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--text-muted); }\n\n.ax-md__code {\n font-family: var(--font-mono); font-size: 0.86em;\n background: var(--bg-3); color: var(--text-body);\n border: 1px solid var(--border-default);\n border-radius: var(--radius-1); padding: 0.12em 0.36em;\n white-space: break-spaces; word-break: break-word;\n}\n[data-theme=\"dark\"] .ax-md__code { background: var(--bg-2); }\n\n.ax-md > .ax-code, .ax-md__li > .ax-code, .ax-md__quote > .ax-code { margin: 0 0 0.7em; }\n\n.ax-md__link {\n color: var(--text-body); text-decoration: underline;\n text-underline-offset: 2px; text-decoration-color: var(--border-strong);\n transition: text-decoration-color var(--dur-1) var(--ease-out);\n word-break: break-word;\n}\n.ax-md__link:hover { text-decoration-color: var(--text-body); }\n\n.ax-md__img {\n display: inline-flex; align-items: center; gap: 6px; vertical-align: baseline;\n padding: 1px 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-1);\n font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-faint);\n}\n.ax-md__img b { font-weight: var(--weight-medium); letter-spacing: var(--tracking-label); }\n\n.ax-md__quote {\n margin: 0 0 0.7em; padding: 2px 0 2px 14px;\n border-left: 2px solid var(--border-strong); color: var(--text-muted);\n}\n.ax-md__quote > :last-child { margin-bottom: 0; }\n.ax-md__quote .ax-md__quote { margin-top: 0.5em; }\n\n.ax-md__hr { border: none; border-top: 1px solid var(--border-default); margin: 1.2em 0; }\n\n.ax-md__tablewrap {\n margin: 0 0 0.7em; overflow-x: auto;\n border: 1px solid var(--border-default); border-radius: var(--radius-2);\n}\n.ax-md__table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }\n.ax-md__table th, .ax-md__table td {\n padding: 7px 12px; text-align: left; vertical-align: top;\n border-bottom: 1px solid var(--border-default); border-right: 1px solid var(--border-default);\n}\n.ax-md__table th:last-child, .ax-md__table td:last-child { border-right: none; }\n.ax-md__table tbody tr:last-child td { border-bottom: none; }\n.ax-md__table thead th {\n background: var(--surface-card); color: var(--text-body);\n font-weight: var(--weight-medium); white-space: nowrap;\n}\n\n.ax-md__h { font-family: var(--font-display); font-weight: var(--weight-medium);\n line-height: var(--leading-snug); letter-spacing: var(--tracking-tight);\n margin: 1.1em 0 0.5em; color: var(--text-body); }\n.ax-md__h--1 { font-size: var(--text-xl); }\n.ax-md__h--2 { font-size: var(--text-lg); }\n.ax-md__h--3 { font-size: var(--text-md); }\n`;\n\nif (typeof document !== \"undefined\" && !document.getElementById(\"ax-md-css\")) {\n const s = document.createElement(\"style\");\n s.id = \"ax-md-css\";\n s.textContent = AX_MD_CSS;\n document.head.appendChild(s);\n}\n\n/* ---- url sanitizer: only allow safe schemes / relative ---- */\nfunction sanitizeUrl(raw) {\n // eslint-disable-next-line no-control-regex\n const url = String(raw || \"\")\n .replace(/[\\u0000-\\u001F\\u007F]/g, \"\")\n .trim();\n if (!url) return null;\n if (/^[a-z][a-z0-9+.-]*:/i.test(url)) {\n if (/^(https?|mailto|tel):/i.test(url)) return url;\n return null; // blocks javascript:, data:, vbscript:, file:, etc.\n }\n return url; // relative, anchor, query, protocol-relative\n}\n\n/* ==================== inline parser ==================== */\n/* string -> React node array. At each position it tries inline\n rules in priority order; a rule fires only when its CLOSING\n delimiter exists, so streamed/partial delimiters fall through\n to literal text. */\nfunction parseInline(text, keyBase) {\n const out = [];\n let buf = \"\";\n let i = 0;\n let k = 0;\n const len = text.length;\n const flush = () => {\n if (buf) {\n out.push(buf);\n buf = \"\";\n }\n };\n\n while (i < len) {\n const ch = text[i];\n const rest = text.slice(i);\n\n if (ch === \"\\n\") {\n flush();\n out.push(<br key={keyBase + \"-br\" + k++} />);\n i++;\n continue;\n }\n\n if (ch === \"\\\\\" && i + 1 < len && /[\\\\`*_{}\\[\\]()#+\\-.!~|>]/.test(text[i + 1])) {\n buf += text[i + 1];\n i += 2;\n continue;\n }\n\n let m;\n // inline code\n if (ch === \"`\" && (m = /^`([^`\\n]+?)`/.exec(rest))) {\n flush();\n out.push(\n <code key={keyBase + \"-c\" + k++} className=\"ax-md__code\">\n {m[1]}\n </code>,\n );\n i += m[0].length;\n continue;\n }\n // image placeholder  — inert, never fetched\n if (ch === \"!\" && text[i + 1] === \"[\" && (m = /^!\\[([^\\]]*)\\]\\(([^)\\s]*)\\)/.exec(rest))) {\n flush();\n out.push(\n <span key={keyBase + \"-img\" + k++} className=\"ax-md__img\" title={m[2]}>\n <b>IMG</b>\n {m[1] ? \" · \" + m[1] : \"\"}\n </span>,\n );\n i += m[0].length;\n continue;\n }\n // link [text](url)\n if (ch === \"[\" && (m = /^\\[([^\\]]*)\\]\\(([^)\\s]*)\\)/.exec(rest))) {\n flush();\n const href = sanitizeUrl(m[2]);\n const inner = parseInline(m[1], keyBase + \"-lt\" + k);\n out.push(\n href ? (\n <a\n key={keyBase + \"-l\" + k++}\n className=\"ax-md__link\"\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n >\n {inner}\n </a>\n ) : (\n <span key={keyBase + \"-l\" + k++}>{inner}</span>\n ),\n );\n i += m[0].length;\n continue;\n }\n // bare-URL autolink (word boundary on the left)\n if (\n (ch === \"h\" || ch === \"w\") &&\n (i === 0 || /[\\s(]/.test(text[i - 1])) &&\n (m = /^((?:https?:\\/\\/|www\\.)[^\\s<>]+)/i.exec(rest))\n ) {\n let urlText = m[1];\n const trail = /[.,;:!?'\")\\]]+$/.exec(urlText);\n if (trail) urlText = urlText.slice(0, urlText.length - trail[0].length);\n const href = sanitizeUrl(/^www\\./i.test(urlText) ? \"http://\" + urlText : urlText);\n if (href) {\n flush();\n out.push(\n <a\n key={keyBase + \"-a\" + k++}\n className=\"ax-md__link\"\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n >\n {urlText}\n </a>,\n );\n i += urlText.length;\n continue;\n }\n }\n // bold ** ** or __ __\n if (ch === \"*\" && (m = /^\\*\\*([\\s\\S]+?)\\*\\*/.exec(rest))) {\n flush();\n out.push(\n <strong key={keyBase + \"-b\" + k++} className=\"ax-md__strong\">\n {parseInline(m[1], keyBase + \"-bt\" + k)}\n </strong>,\n );\n i += m[0].length;\n continue;\n }\n if (ch === \"_\" && (m = /^__([\\s\\S]+?)__/.exec(rest))) {\n flush();\n out.push(\n <strong key={keyBase + \"-b\" + k++} className=\"ax-md__strong\">\n {parseInline(m[1], keyBase + \"-bt\" + k)}\n </strong>,\n );\n i += m[0].length;\n continue;\n }\n // strikethrough ~~ ~~\n if (ch === \"~\" && (m = /^~~([\\s\\S]+?)~~/.exec(rest))) {\n flush();\n out.push(\n <del key={keyBase + \"-s\" + k++} className=\"ax-md__del\">\n {parseInline(m[1], keyBase + \"-st\" + k)}\n </del>,\n );\n i += m[0].length;\n continue;\n }\n // italic * * or _ _ (no adjacent whitespace)\n if (ch === \"*\" && (m = /^\\*(?!\\s)([^*]+?)(?<!\\s)\\*/.exec(rest))) {\n flush();\n out.push(\n <em key={keyBase + \"-i\" + k++} className=\"ax-md__em\">\n {parseInline(m[1], keyBase + \"-it\" + k)}\n </em>,\n );\n i += m[0].length;\n continue;\n }\n if (ch === \"_\" && (m = /^_(?!\\s)([^_]+?)(?<!\\s)_/.exec(rest))) {\n flush();\n out.push(\n <em key={keyBase + \"-i\" + k++} className=\"ax-md__em\">\n {parseInline(m[1], keyBase + \"-it\" + k)}\n </em>,\n );\n i += m[0].length;\n continue;\n }\n\n buf += ch;\n i++;\n }\n flush();\n return out;\n}\n\n/* ==================== block parser ==================== */\nconst RE_FENCE = /^(\\s{0,3})(`{3,}|~{3,})\\s*([\\w+#.-]*)\\s*$/;\nconst RE_HEADING = /^(#{1,6})\\s+(.*)$/;\nconst RE_HR = /^\\s{0,3}([-*_])(?:\\s*\\1){2,}\\s*$/;\nconst RE_BLANK = /^\\s*$/;\nconst RE_QUOTE = /^\\s*>/;\nconst RE_LIST_ITEM = /^([ \\t]*)([-*+]|\\d{1,9}[.)])\\s+(.*)$/;\n\nfunction leadingSpaces(s) {\n const m = /^[ \\t]*/.exec(s);\n return m[0].length;\n}\n\nfunction listMarkerInfo(line) {\n const m = RE_LIST_ITEM.exec(line);\n if (!m) return null;\n const ordered = /\\d/.test(m[2]);\n return {\n indent: m[1].length,\n bullet: ordered ? \"ol\" : \"ul\",\n start: ordered ? parseInt(m[2], 10) : null,\n text: m[3],\n raw: m[0],\n };\n}\n\nfunction splitTableRow(row) {\n let s = row.trim();\n if (s.startsWith(\"|\")) s = s.slice(1);\n if (s.endsWith(\"|\")) s = s.slice(0, -1);\n return s.split(/(?<!\\\\)\\|/).map((c) => c.trim().replace(/\\\\\\|/g, \"|\"));\n}\n\nfunction isTableSep(line) {\n if (!line.includes(\"|\")) return false;\n const cells = splitTableRow(line);\n return cells.length > 0 && cells.every((c) => /^:?-{1,}:?$/.test(c.trim()));\n}\n\nfunction alignOf(cell) {\n const c = cell.trim();\n const l = c.startsWith(\":\"),\n r = c.endsWith(\":\");\n if (l && r) return \"center\";\n if (r) return \"right\";\n if (l) return \"left\";\n return null;\n}\n\nfunction startsBlock(lines, i) {\n const line = lines[i];\n if (RE_FENCE.test(line)) return true;\n if (RE_HR.test(line)) return true;\n if (RE_HEADING.test(line)) return true;\n if (RE_QUOTE.test(line)) return true;\n if (listMarkerInfo(line)) return true;\n if (line.includes(\"|\") && i + 1 < lines.length && isTableSep(lines[i + 1])) return true;\n return false;\n}\n\nfunction parseList(lines, i) {\n const base = leadingSpaces(lines[i]);\n const baseInfo = listMarkerInfo(lines[i]);\n const type = baseInfo.bullet;\n const start = baseInfo.start;\n const items = [];\n\n while (i < lines.length) {\n if (RE_BLANK.test(lines[i])) {\n let j = i;\n while (j < lines.length && RE_BLANK.test(lines[j])) j++;\n const info = j < lines.length ? listMarkerInfo(lines[j]) : null;\n if (\n j < lines.length &&\n ((info && leadingSpaces(lines[j]) === base) || leadingSpaces(lines[j]) > base)\n ) {\n i = j;\n continue;\n }\n break;\n }\n const ind = leadingSpaces(lines[i]);\n const info = listMarkerInfo(lines[i]);\n if (info && ind === base && info.bullet === type) {\n const markerWidth = info.raw.length - info.text.length;\n const itemLines = [info.text];\n i++;\n while (i < lines.length) {\n if (RE_BLANK.test(lines[i])) {\n let j = i;\n while (j < lines.length && RE_BLANK.test(lines[j])) j++;\n if (j < lines.length && leadingSpaces(lines[j]) > base) {\n itemLines.push(\"\");\n i++;\n continue;\n }\n break;\n }\n if (leadingSpaces(lines[i]) > base) {\n itemLines.push(lines[i].slice(Math.min(markerWidth, leadingSpaces(lines[i]))));\n i++;\n } else break;\n }\n while (itemLines.length && itemLines[itemLines.length - 1] === \"\") itemLines.pop();\n\n let checked = null;\n const tm = /^\\[([ xX])\\]\\s+([\\s\\S]*)$/.exec(itemLines[0] || \"\");\n if (tm) {\n checked = tm[1].toLowerCase() === \"x\";\n itemLines[0] = tm[2];\n }\n\n items.push({ checked, blocks: parseBlocks(itemLines.join(\"\\n\")) });\n } else {\n break; // sibling of different type, dedent, or non-list line ends the list\n }\n }\n return { type, start, items, next: i };\n}\n\nfunction parseBlocks(src) {\n const lines = String(src || \"\")\n .replace(/\\r\\n?/g, \"\\n\")\n .split(\"\\n\");\n const blocks = [];\n let i = 0;\n\n while (i < lines.length) {\n const line = lines[i];\n\n // fenced code (tolerates a missing closing fence)\n const fence = RE_FENCE.exec(line);\n if (fence) {\n const mark = fence[2][0];\n const len = fence[2].length;\n const close = new RegExp(\"^\\\\s{0,3}\" + mark + \"{\" + len + \",}\\\\s*$\");\n i++;\n const code = [];\n while (i < lines.length && !close.test(lines[i])) {\n code.push(lines[i]);\n i++;\n }\n if (i < lines.length) i++;\n blocks.push({ type: \"code\", lang: fence[3] || \"\", code: code.join(\"\\n\") });\n continue;\n }\n\n if (RE_BLANK.test(line)) {\n i++;\n continue;\n }\n\n if (RE_HR.test(line)) {\n blocks.push({ type: \"hr\" });\n i++;\n continue;\n }\n\n const h = RE_HEADING.exec(line);\n if (h) {\n blocks.push({ type: \"heading\", level: h[1].length, text: h[2] });\n i++;\n continue;\n }\n\n // blockquote — strip one '>' level, recurse (enables nesting + inner blocks)\n if (RE_QUOTE.test(line)) {\n const inner = [];\n while (i < lines.length && RE_QUOTE.test(lines[i])) {\n inner.push(lines[i].replace(/^\\s*>\\s?/, \"\"));\n i++;\n }\n blocks.push({ type: \"quote\", blocks: parseBlocks(inner.join(\"\\n\")) });\n continue;\n }\n\n // GFM table (header + separator). Half tables render their partial rows.\n if (line.includes(\"|\") && i + 1 < lines.length && isTableSep(lines[i + 1])) {\n const header = splitTableRow(line);\n const aligns = splitTableRow(lines[i + 1]).map(alignOf);\n i += 2;\n const rows = [];\n while (\n i < lines.length &&\n !RE_BLANK.test(lines[i]) &&\n lines[i].includes(\"|\") &&\n !RE_FENCE.test(lines[i]) &&\n !RE_QUOTE.test(lines[i])\n ) {\n rows.push(splitTableRow(lines[i]));\n i++;\n }\n blocks.push({ type: \"table\", header, aligns, rows });\n continue;\n }\n\n // lists (nested + mixed handled recursively)\n if (listMarkerInfo(line)) {\n const res = parseList(lines, i);\n blocks.push({ type: \"list\", listType: res.type, start: res.start, items: res.items });\n i = res.next;\n continue;\n }\n\n // paragraph\n const para = [line];\n i++;\n while (i < lines.length && !RE_BLANK.test(lines[i]) && !startsBlock(lines, i)) {\n para.push(lines[i]);\n i++;\n }\n blocks.push({ type: \"p\", text: para.join(\"\\n\") });\n }\n\n return blocks;\n}\n\n/* ==================== render ==================== */\nfunction renderItemContent(blocks, key) {\n if (blocks.length === 1 && blocks[0].type === \"p\") return parseInline(blocks[0].text, key);\n return blocks.map((b, j) =>\n b.type === \"p\" ? (\n <React.Fragment key={j}>{parseInline(b.text, key + \"-\" + j)}</React.Fragment>\n ) : (\n renderBlock(b, key + \"-\" + j)\n ),\n );\n}\n\nfunction renderList(b, key) {\n const Tag = b.listType === \"ol\" ? \"ol\" : \"ul\";\n const cls = b.listType === \"ol\" ? \"ax-md__ol\" : \"ax-md__ul\";\n const startAttr = b.listType === \"ol\" && b.start && b.start !== 1 ? b.start : undefined;\n return (\n <Tag key={key} className={cls} start={startAttr}>\n {b.items.map((it, j) => {\n const content = renderItemContent(it.blocks, key + \"-\" + j);\n if (it.checked !== null) {\n return (\n <li key={j} className=\"ax-md__li ax-md__li--task\">\n <input\n type=\"checkbox\"\n className=\"ax-md__check\"\n checked={it.checked}\n disabled\n readOnly\n />\n <span className=\"ax-md__taskbody\">{content}</span>\n </li>\n );\n }\n return (\n <li key={j} className=\"ax-md__li\">\n {content}\n </li>\n );\n })}\n </Tag>\n );\n}\n\nfunction renderTable(b, key) {\n const cols = b.header.length;\n return (\n <div key={key} className=\"ax-md__tablewrap\">\n <table className=\"ax-md__table\">\n <thead>\n <tr>\n {b.header.map((c, ci) => (\n <th key={ci} style={{ textAlign: b.aligns[ci] || \"left\" }}>\n {parseInline(c, key + \"-h\" + ci)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {b.rows.map((r, ri) => (\n <tr key={ri}>\n {Array.from({ length: cols }).map((_, ci) => (\n <td key={ci} style={{ textAlign: b.aligns[ci] || \"left\" }}>\n {parseInline(r[ci] || \"\", key + \"-r\" + ri + \"c\" + ci)}\n </td>\n ))}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n}\n\nfunction renderBlock(b, key) {\n switch (b.type) {\n case \"code\":\n return <CodeBlock key={key} code={b.code} lang={b.lang || \"text\"} />;\n case \"hr\":\n return <hr key={key} className=\"ax-md__hr\" />;\n case \"quote\":\n return (\n <blockquote key={key} className=\"ax-md__quote\">\n {renderBlocks(b.blocks, key)}\n </blockquote>\n );\n case \"table\":\n return renderTable(b, key);\n case \"list\":\n return renderList(b, key);\n case \"heading\": {\n const lvl = Math.min(b.level, 3);\n const Tag = \"h\" + Math.min(b.level + 1, 6);\n return (\n <Tag key={key} className={\"ax-md__h ax-md__h--\" + lvl}>\n {parseInline(b.text, key)}\n </Tag>\n );\n }\n case \"p\":\n default:\n return (\n <p key={key} className=\"ax-md__p\">\n {parseInline(b.text, key)}\n </p>\n );\n }\n}\n\nfunction renderBlocks(blocks, keyBase) {\n return blocks.map((b, idx) => renderBlock(b, keyBase + \"-blk\" + idx));\n}\n\nexport function Markdown({ content, children, className = \"\", ...rest }) {\n const src = typeof content === \"string\" ? content : typeof children === \"string\" ? children : \"\";\n const blocks = React.useMemo(() => parseBlocks(src), [src]);\n const cls = [\"ax-md\", className].filter(Boolean).join(\" \");\n return (\n <div className={cls} {...rest}>\n {renderBlocks(blocks, \"md\")}\n </div>\n );\n}\n"],"names":["info"],"mappings":";;;AA0BA,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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,IAAI,EAAE,OAAO,CAAC;AAC/B,YAAM,MAAM,MAAM,KAAK,IAAI,EAAE,QAAQ,GAAG,CAAC;AACzC,aACE,oBAAC,KAAA,EAAc,WAAW,wBAAwB,KAC/C,sBAAY,EAAE,MAAM,GAAG,EAAA,GADhB,GAEV;AAAA,IAEJ;AAAA,IACA,KAAK;AAAA,IACL;AACE,aACE,oBAAC,OAAY,WAAU,YACpB,sBAAY,EAAE,MAAM,GAAG,EAAA,GADlB,GAER;AAAA,EAAA;AAGR;AAEA,SAAS,aAAa,QAAQ,SAAS;AACrC,SAAO,OAAO,IAAI,CAAC,GAAG,QAAQ,YAAY,GAAG,UAAU,SAAS,GAAG,CAAC;AACtE;AAEO,SAAS,SAAS,EAAE,SAAS,UAAU,YAAY,IAAI,GAAG,QAAQ;AACvE,QAAM,MAAM,OAAO,YAAY,WAAW,UAAU,OAAO,aAAa,WAAW,WAAW;AAC9F,QAAM,SAAS,MAAM,QAAQ,MAAM,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC;AAC1D,QAAM,MAAM,CAAC,SAAS,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACzD,SACE,oBAAC,SAAI,WAAW,KAAM,GAAG,MACtB,UAAA,aAAa,QAAQ,IAAI,EAAA,CAC5B;AAEJ;"}
|
|
@@ -11,6 +11,12 @@ export interface MessageProps {
|
|
|
11
11
|
time?: string;
|
|
12
12
|
/** Append a blinking block cursor (response in progress). @default false */
|
|
13
13
|
streaming?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Markdown source for the body, rendered through <Markdown>. Overrides
|
|
16
|
+
* `children`. (A plain string passed as `children` is also auto-rendered
|
|
17
|
+
* as markdown; React-node children render unchanged for back-compat.)
|
|
18
|
+
*/
|
|
19
|
+
markdown?: string;
|
|
14
20
|
children?: React.ReactNode;
|
|
15
21
|
}
|
|
16
22
|
export declare function Message(props: MessageProps): JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
+
import { Markdown } from "./Markdown.js";
|
|
3
4
|
const AX_MSG_CSS = `
|
|
4
5
|
.ax-msg { display: flex; flex-direction: column; }
|
|
5
6
|
.ax-msg--user { align-items: flex-end; }
|
|
@@ -40,19 +41,28 @@ function Message({
|
|
|
40
41
|
name,
|
|
41
42
|
time,
|
|
42
43
|
streaming = false,
|
|
44
|
+
markdown,
|
|
43
45
|
children,
|
|
44
46
|
className = "",
|
|
45
47
|
...rest
|
|
46
48
|
}) {
|
|
47
49
|
const isUser = role === "user";
|
|
48
50
|
const cls = ["ax-msg", isUser ? "ax-msg--user" : "ax-msg--assistant", className].filter(Boolean).join(" ");
|
|
51
|
+
let body;
|
|
52
|
+
if (typeof markdown === "string") {
|
|
53
|
+
body = /* @__PURE__ */ jsx(Markdown, { content: markdown });
|
|
54
|
+
} else if (typeof children === "string") {
|
|
55
|
+
body = /* @__PURE__ */ jsx(Markdown, { content: children });
|
|
56
|
+
} else {
|
|
57
|
+
body = children;
|
|
58
|
+
}
|
|
49
59
|
return /* @__PURE__ */ jsxs("div", { className: cls, ...rest, children: [
|
|
50
60
|
!isUser ? /* @__PURE__ */ jsxs("div", { className: "ax-msg__head", children: [
|
|
51
61
|
/* @__PURE__ */ jsx("span", { className: "ax-msg__name", children: name || "Agentaily" }),
|
|
52
62
|
time ? /* @__PURE__ */ jsx("span", { className: "ax-msg__time", children: time }) : null
|
|
53
63
|
] }) : null,
|
|
54
64
|
/* @__PURE__ */ jsxs("div", { className: "ax-msg__body", children: [
|
|
55
|
-
|
|
65
|
+
body,
|
|
56
66
|
streaming ? /* @__PURE__ */ jsx("span", { className: "ax-msg__cursor" }) : null
|
|
57
67
|
] })
|
|
58
68
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sources":["../../../src/components/chat/Message.jsx"],"sourcesContent":["import React from \"react\";\n\nconst AX_MSG_CSS = `\n.ax-msg { display: flex; flex-direction: column; }\n.ax-msg--user { align-items: flex-end; }\n.ax-msg--user .ax-msg__body {\n max-width: 78%;\n background: var(--surface-card);\n border: 1px solid var(--border-default);\n border-radius: var(--radius-3);\n padding: 10px 14px;\n}\n.ax-msg--assistant { align-items: stretch; }\n.ax-msg__head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }\n.ax-msg__name {\n font-family: var(--font-mono); font-size: var(--text-xs);\n font-weight: var(--weight-medium); letter-spacing: var(--tracking-label);\n text-transform: uppercase; color: var(--text-faint);\n}\n.ax-msg__time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-faint); opacity: 0.7; }\n.ax-msg__body { font-size: var(--text-md); line-height: var(--leading-body); color: var(--text-body); min-width: 0; }\n.ax-msg__body > p { margin: 0 0 0.7em; }\n.ax-msg__body > p:last-child { margin-bottom: 0; }\n.ax-msg__cursor {\n display: inline-block; width: 0.55em; height: 1.05em;\n background: currentColor; vertical-align: text-bottom; margin-left: 2px;\n animation: ax-msg-blink 1.1s steps(1) infinite;\n}\n@keyframes ax-msg-blink { 50% { opacity: 0; } }\n@media (prefers-reduced-motion: reduce) { .ax-msg__cursor { animation: none; } }\n`;\n\nif (typeof document !== \"undefined\" && !document.getElementById(\"ax-msg-css\")) {\n const s = document.createElement(\"style\");\n s.id = \"ax-msg-css\";\n s.textContent = AX_MSG_CSS;\n document.head.appendChild(s);\n}\n\nexport function Message({\n role = \"assistant\",\n name,\n time,\n streaming = false,\n children,\n className = \"\",\n ...rest\n}) {\n const isUser = role === \"user\";\n const cls = [\"ax-msg\", isUser ? \"ax-msg--user\" : \"ax-msg--assistant\", className].filter(Boolean).join(\" \");\n return (\n <div className={cls} {...rest}>\n {!isUser ? (\n <div className=\"ax-msg__head\">\n <span className=\"ax-msg__name\">{name || \"Agentaily\"}</span>\n {time ? <span className=\"ax-msg__time\">{time}</span> : null}\n </div>\n ) : null}\n <div className=\"ax-msg__body\">\n {
|
|
1
|
+
{"version":3,"file":"Message.js","sources":["../../../src/components/chat/Message.jsx"],"sourcesContent":["import React from \"react\";\nimport { Markdown } from \"./Markdown.jsx\";\n\nconst AX_MSG_CSS = `\n.ax-msg { display: flex; flex-direction: column; }\n.ax-msg--user { align-items: flex-end; }\n.ax-msg--user .ax-msg__body {\n max-width: 78%;\n background: var(--surface-card);\n border: 1px solid var(--border-default);\n border-radius: var(--radius-3);\n padding: 10px 14px;\n}\n.ax-msg--assistant { align-items: stretch; }\n.ax-msg__head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }\n.ax-msg__name {\n font-family: var(--font-mono); font-size: var(--text-xs);\n font-weight: var(--weight-medium); letter-spacing: var(--tracking-label);\n text-transform: uppercase; color: var(--text-faint);\n}\n.ax-msg__time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-faint); opacity: 0.7; }\n.ax-msg__body { font-size: var(--text-md); line-height: var(--leading-body); color: var(--text-body); min-width: 0; }\n.ax-msg__body > p { margin: 0 0 0.7em; }\n.ax-msg__body > p:last-child { margin-bottom: 0; }\n.ax-msg__cursor {\n display: inline-block; width: 0.55em; height: 1.05em;\n background: currentColor; vertical-align: text-bottom; margin-left: 2px;\n animation: ax-msg-blink 1.1s steps(1) infinite;\n}\n@keyframes ax-msg-blink { 50% { opacity: 0; } }\n@media (prefers-reduced-motion: reduce) { .ax-msg__cursor { animation: none; } }\n`;\n\nif (typeof document !== \"undefined\" && !document.getElementById(\"ax-msg-css\")) {\n const s = document.createElement(\"style\");\n s.id = \"ax-msg-css\";\n s.textContent = AX_MSG_CSS;\n document.head.appendChild(s);\n}\n\nexport function Message({\n role = \"assistant\",\n name,\n time,\n streaming = false,\n markdown,\n children,\n className = \"\",\n ...rest\n}) {\n const isUser = role === \"user\";\n const cls = [\"ax-msg\", isUser ? \"ax-msg--user\" : \"ax-msg--assistant\", className]\n .filter(Boolean)\n .join(\" \");\n\n // Back-compat: React-node children render as-is. A markdown string (via the\n // `markdown` prop, or a plain string passed as children) routes through\n // <Markdown> so model output is typeset without breaking existing usage.\n let body;\n if (typeof markdown === \"string\") {\n body = <Markdown content={markdown} />;\n } else if (typeof children === \"string\") {\n body = <Markdown content={children} />;\n } else {\n body = children;\n }\n\n return (\n <div className={cls} {...rest}>\n {!isUser ? (\n <div className=\"ax-msg__head\">\n <span className=\"ax-msg__name\">{name || \"Agentaily\"}</span>\n {time ? <span className=\"ax-msg__time\">{time}</span> : null}\n </div>\n ) : null}\n <div className=\"ax-msg__body\">\n {body}\n {streaming ? <span className=\"ax-msg__cursor\"></span> : null}\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BnB,IAAI,OAAO,aAAa,eAAe,CAAC,SAAS,eAAe,YAAY,GAAG;AAC7E,QAAM,IAAI,SAAS,cAAc,OAAO;AACxC,IAAE,KAAK;AACP,IAAE,cAAc;AAChB,WAAS,KAAK,YAAY,CAAC;AAC7B;AAEO,SAAS,QAAQ;AAAA,EACtB,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL,GAAG;AACD,QAAM,SAAS,SAAS;AACxB,QAAM,MAAM,CAAC,UAAU,SAAS,iBAAiB,qBAAqB,SAAS,EAC5E,OAAO,OAAO,EACd,KAAK,GAAG;AAKX,MAAI;AACJ,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO,oBAAC,UAAA,EAAS,SAAS,SAAA,CAAU;AAAA,EACtC,WAAW,OAAO,aAAa,UAAU;AACvC,WAAO,oBAAC,UAAA,EAAS,SAAS,SAAA,CAAU;AAAA,EACtC,OAAO;AACL,WAAO;AAAA,EACT;AAEA,SACE,qBAAC,OAAA,EAAI,WAAW,KAAM,GAAG,MACtB,UAAA;AAAA,IAAA,CAAC,SACA,qBAAC,OAAA,EAAI,WAAU,gBACb,UAAA;AAAA,MAAA,oBAAC,QAAA,EAAK,WAAU,gBAAgB,UAAA,QAAQ,aAAY;AAAA,MACnD,OAAO,oBAAC,QAAA,EAAK,WAAU,gBAAgB,gBAAK,IAAU;AAAA,IAAA,EAAA,CACzD,IACE;AAAA,IACJ,qBAAC,OAAA,EAAI,WAAU,gBACZ,UAAA;AAAA,MAAA;AAAA,MACA,YAAY,oBAAC,QAAA,EAAK,WAAU,kBAAiB,IAAU;AAAA,IAAA,EAAA,CAC1D;AAAA,EAAA,GACF;AAEJ;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from "./components/buttons/IconButton";
|
|
|
30
30
|
export * from "./components/chat/CodeBlock";
|
|
31
31
|
export * from "./components/chat/Composer";
|
|
32
32
|
export * from "./components/chat/ConversationThread";
|
|
33
|
+
export * from "./components/chat/Markdown";
|
|
33
34
|
export * from "./components/chat/Message";
|
|
34
35
|
|
|
35
36
|
// code
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { IconButton } from "./components/buttons/IconButton.js";
|
|
|
21
21
|
import { CodeBlock } from "./components/chat/CodeBlock.js";
|
|
22
22
|
import { Composer } from "./components/chat/Composer.js";
|
|
23
23
|
import { ConversationThread } from "./components/chat/ConversationThread.js";
|
|
24
|
+
import { Markdown } from "./components/chat/Markdown.js";
|
|
24
25
|
import { Message } from "./components/chat/Message.js";
|
|
25
26
|
import { Agent } from "./components/code/Agent.js";
|
|
26
27
|
import { Artifact } from "./components/code/Artifact.js";
|
|
@@ -182,6 +183,7 @@ export {
|
|
|
182
183
|
Kbd,
|
|
183
184
|
Label,
|
|
184
185
|
LineChart,
|
|
186
|
+
Markdown,
|
|
185
187
|
MarkupLayer,
|
|
186
188
|
Menubar,
|
|
187
189
|
Message,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentaily/design-system",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Agentaily design system — light-first monochrome React component library (
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Agentaily design system — light-first monochrome React component library (115 components) + Storybook.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Agentaily",
|