@adecore/agents-react 0.46.1 → 0.46.2
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/dist/chat/ui/Markdown.js +27 -6
- package/package.json +8 -8
- package/src/chat/ui/Markdown.tsx +16 -3
package/dist/chat/ui/Markdown.js
CHANGED
|
@@ -89,6 +89,29 @@ function languageOf(className) {
|
|
|
89
89
|
return /language-([\w-]+)/.exec(className ?? '')?.[1] ?? 'text';
|
|
90
90
|
}
|
|
91
91
|
const INLINE_CODE = 'rounded-sm bg-surface-sunken px-1 py-px font-mono text-code box-decoration-clone';
|
|
92
|
+
/* A double-click selects a word, which ends at a hyphen or a dot, so a flag or a command would be copied in parts. */
|
|
93
|
+
function selectWholeCode(event) {
|
|
94
|
+
window.getSelection()?.selectAllChildren(event.currentTarget);
|
|
95
|
+
}
|
|
96
|
+
function PlainCode(t0) {
|
|
97
|
+
const $ = _c(2);
|
|
98
|
+
const {
|
|
99
|
+
text
|
|
100
|
+
} = t0;
|
|
101
|
+
let t1;
|
|
102
|
+
if ($[0] !== text) {
|
|
103
|
+
t1 = /*#__PURE__*/_jsx("code", {
|
|
104
|
+
className: INLINE_CODE,
|
|
105
|
+
onDoubleClick: selectWholeCode,
|
|
106
|
+
children: text
|
|
107
|
+
});
|
|
108
|
+
$[0] = text;
|
|
109
|
+
$[1] = t1;
|
|
110
|
+
} else {
|
|
111
|
+
t1 = $[1];
|
|
112
|
+
}
|
|
113
|
+
return t1;
|
|
114
|
+
}
|
|
92
115
|
/*
|
|
93
116
|
* A path an agent wrote down. It keeps the shape of the code chip it would otherwise be, so a sentence
|
|
94
117
|
* full of them does not shift; `data-file-path` is what the thread's right-click menu reads.
|
|
@@ -165,9 +188,8 @@ function InlineCode(t0) {
|
|
|
165
188
|
if (target === null) {
|
|
166
189
|
let t1;
|
|
167
190
|
if ($[0] !== text) {
|
|
168
|
-
t1 = /*#__PURE__*/_jsx(
|
|
169
|
-
|
|
170
|
-
children: text
|
|
191
|
+
t1 = /*#__PURE__*/_jsx(PlainCode, {
|
|
192
|
+
text: text
|
|
171
193
|
});
|
|
172
194
|
$[0] = text;
|
|
173
195
|
$[1] = t1;
|
|
@@ -486,9 +508,8 @@ function MarkdownCode(t0) {
|
|
|
486
508
|
}
|
|
487
509
|
let t2;
|
|
488
510
|
if ($[8] !== plain || $[9] !== text) {
|
|
489
|
-
t2 = plain ? /*#__PURE__*/_jsx(
|
|
490
|
-
|
|
491
|
-
children: text
|
|
511
|
+
t2 = plain ? /*#__PURE__*/_jsx(PlainCode, {
|
|
512
|
+
text: text
|
|
492
513
|
}) : /*#__PURE__*/_jsx(InlineCode, {
|
|
493
514
|
text: text
|
|
494
515
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/agents-react",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.2",
|
|
4
4
|
"description": "React agent chat threads, composers, approvals, provider accounts and usage views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"test:visuals": "bun --config=integration.bunfig.toml --conditions=source test ./src/chat/visual-viewport.integration.test.ts"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@adecore/agent-contracts": "0.46.
|
|
76
|
-
"@adecore/editor": "0.46.
|
|
77
|
-
"@adecore/editor-react": "0.46.
|
|
78
|
-
"@adecore/intelligent-ui": "0.46.
|
|
79
|
-
"@adecore/merge": "0.46.
|
|
75
|
+
"@adecore/agent-contracts": "0.46.2",
|
|
76
|
+
"@adecore/editor": "0.46.2",
|
|
77
|
+
"@adecore/editor-react": "0.46.2",
|
|
78
|
+
"@adecore/intelligent-ui": "0.46.2",
|
|
79
|
+
"@adecore/merge": "0.46.2",
|
|
80
80
|
"@codemirror/commands": "^6.11.1",
|
|
81
81
|
"@codemirror/language": "^6.13.1",
|
|
82
82
|
"@codemirror/state": "^6.7.6",
|
|
@@ -100,14 +100,14 @@
|
|
|
100
100
|
"zustand": "^5.0.16"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@adecore/ui": "^0.46.
|
|
103
|
+
"@adecore/ui": "^0.46.2",
|
|
104
104
|
"i18next": "^26.4.2",
|
|
105
105
|
"react": "^19.3.0",
|
|
106
106
|
"react-dom": "^19.3.0",
|
|
107
107
|
"react-i18next": "^17.0.15"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@adecore/ui": "0.46.
|
|
110
|
+
"@adecore/ui": "0.46.2",
|
|
111
111
|
"@types/bun": "^1.4.4",
|
|
112
112
|
"@types/react": "^19.3.0",
|
|
113
113
|
"@types/react-dom": "^19.3.0",
|
package/src/chat/ui/Markdown.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, memo, useContext, type ComponentProps, type ReactNode } from 'react';
|
|
1
|
+
import { createContext, memo, useContext, type ComponentProps, type MouseEvent, type ReactNode } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { Zap } from 'lucide-react';
|
|
4
4
|
import ReactMarkdown, { type Components, type ExtraProps, type Options } from 'react-markdown';
|
|
@@ -101,6 +101,19 @@ function languageOf(className: string | undefined): string {
|
|
|
101
101
|
|
|
102
102
|
const INLINE_CODE = 'rounded-sm bg-surface-sunken px-1 py-px font-mono text-code box-decoration-clone';
|
|
103
103
|
|
|
104
|
+
/* A double-click selects a word, which ends at a hyphen or a dot, so a flag or a command would be copied in parts. */
|
|
105
|
+
function selectWholeCode(event: MouseEvent<HTMLElement>): void {
|
|
106
|
+
window.getSelection()?.selectAllChildren(event.currentTarget);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function PlainCode({ text }: { text: string }) {
|
|
110
|
+
return (
|
|
111
|
+
<code className={INLINE_CODE} onDoubleClick={selectWholeCode}>
|
|
112
|
+
{text}
|
|
113
|
+
</code>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
104
117
|
/*
|
|
105
118
|
* A path an agent wrote down. It keeps the shape of the code chip it would otherwise be, so a sentence
|
|
106
119
|
* full of them does not shift; `data-file-path` is what the thread's right-click menu reads.
|
|
@@ -134,7 +147,7 @@ function InlineCode({ text }: { text: string }) {
|
|
|
134
147
|
const target = useFileLinkTarget(text);
|
|
135
148
|
|
|
136
149
|
if (target === null) {
|
|
137
|
-
return <
|
|
150
|
+
return <PlainCode text={text} />;
|
|
138
151
|
}
|
|
139
152
|
|
|
140
153
|
return (
|
|
@@ -244,7 +257,7 @@ function MarkdownCode({ className, children, plain = false }: { className?: stri
|
|
|
244
257
|
return lang === 'mermaid' ? <Diagram code={code} /> : <CodeBlock code={code} lang={lang} />;
|
|
245
258
|
}
|
|
246
259
|
|
|
247
|
-
return plain ? <
|
|
260
|
+
return plain ? <PlainCode text={text} /> : <InlineCode text={text} />;
|
|
248
261
|
}
|
|
249
262
|
|
|
250
263
|
const components = {
|