funda-ui 4.6.151 → 4.6.222
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/Chatbox/index.css +70 -13
- package/Chatbox/index.d.ts +1 -0
- package/Chatbox/index.js +351 -268
- package/lib/cjs/Chatbox/index.d.ts +1 -0
- package/lib/cjs/Chatbox/index.js +351 -268
- package/lib/css/Chatbox/index.css +70 -13
- package/lib/esm/Chatbox/PureLoader.tsx +4 -2
- package/lib/esm/Chatbox/TypingEffect.tsx +12 -41
- package/lib/esm/Chatbox/index.scss +92 -23
- package/lib/esm/Chatbox/index.tsx +66 -29
- package/lib/esm/Chatbox/utils/func.ts +52 -1
- package/lib/esm/Textarea/index.tsx +0 -2
- package/package.json +1 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// app.ts
|
|
2
2
|
import type { ChatboxProps } from '../index';
|
|
3
3
|
|
|
4
|
+
export interface HtmlTagPlaceholder {
|
|
5
|
+
original: string;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
type: 'table' | 'img' | 'svg';
|
|
8
|
+
}
|
|
4
9
|
|
|
5
10
|
export function isValidJSON(str: string){
|
|
6
11
|
try {
|
|
@@ -13,7 +18,7 @@ export function isValidJSON(str: string){
|
|
|
13
18
|
|
|
14
19
|
export function formatLatestDisplayContent(str: string) {
|
|
15
20
|
// Regular expression to match <details> tags and their content
|
|
16
|
-
|
|
21
|
+
let output = str.replace(/<details class="think"[^>]*>([\s\S]*?)<\/details>/g, (match, content) => {
|
|
17
22
|
// Use regex to match the content inside the "div.think-content"
|
|
18
23
|
const thinkContentMatch = content.match(/<div class="think-content">([\s\S]*?)<\/div>/);
|
|
19
24
|
|
|
@@ -28,6 +33,12 @@ export function formatLatestDisplayContent(str: string) {
|
|
|
28
33
|
|
|
29
34
|
return match; // If not empty, return the original matched content
|
|
30
35
|
});
|
|
36
|
+
|
|
37
|
+
// Then handle tables without is-init class
|
|
38
|
+
output = output.replace(/<table(?![^>]*\bis-init\b)([^>]*)>([\s\S]*?)<\/table>/g, (match, attributes, content) => {
|
|
39
|
+
// Add is-init class to table and wrap it in container div
|
|
40
|
+
return `<div class="table-container"><table class="is-init"${attributes}>${content}</table></div>`;
|
|
41
|
+
});
|
|
31
42
|
|
|
32
43
|
return output;
|
|
33
44
|
}
|
|
@@ -127,3 +138,43 @@ export function isStreamResponse(response: Response): boolean {
|
|
|
127
138
|
return response.body instanceof ReadableStream;
|
|
128
139
|
};
|
|
129
140
|
|
|
141
|
+
|
|
142
|
+
export function extractHtmlTags(html: string): { processedHtml: string; placeholders: HtmlTagPlaceholder[] } {
|
|
143
|
+
const placeholders: HtmlTagPlaceholder[] = [];
|
|
144
|
+
let processedHtml = html;
|
|
145
|
+
|
|
146
|
+
// <table>
|
|
147
|
+
processedHtml = processedHtml.replace(/<table[^>]*>[\s\S]*?<\/table>/g, (match) => {
|
|
148
|
+
const placeholder = `[TABLE_${placeholders.length}]`;
|
|
149
|
+
placeholders.push({
|
|
150
|
+
original: `<div class="table-container">${match?.replace('<table', '<table class="is-init"')}</div>`,
|
|
151
|
+
placeholder,
|
|
152
|
+
type: 'table'
|
|
153
|
+
});
|
|
154
|
+
return placeholder;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// <img>
|
|
158
|
+
processedHtml = processedHtml.replace(/<img[^>]*>/g, (match) => {
|
|
159
|
+
const placeholder = `[IMG_${placeholders.length}]`;
|
|
160
|
+
placeholders.push({
|
|
161
|
+
original: match,
|
|
162
|
+
placeholder,
|
|
163
|
+
type: 'img'
|
|
164
|
+
});
|
|
165
|
+
return placeholder;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// <svg>
|
|
169
|
+
processedHtml = processedHtml.replace(/<svg[^>]*>[\s\S]*?<\/svg>/g, (match) => {
|
|
170
|
+
const placeholder = `[SVG_${placeholders.length}]`;
|
|
171
|
+
placeholders.push({
|
|
172
|
+
original: match,
|
|
173
|
+
placeholder,
|
|
174
|
+
type: 'svg'
|
|
175
|
+
});
|
|
176
|
+
return placeholder;
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
return { processedHtml, placeholders };
|
|
180
|
+
};
|
|
@@ -7,8 +7,6 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
|
7
7
|
import { actualPropertyValue, getTextTop } from 'funda-utils/dist/cjs/inputsCalculation';
|
|
8
8
|
import useDebounce from 'funda-utils/dist/cjs/useDebounce';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
export type TextareaProps = {
|
|
13
11
|
contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
|
|
14
12
|
wrapperClassName?: string;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "UIUX Lab",
|
|
3
3
|
"email": "uiuxlab@gmail.com",
|
|
4
4
|
"name": "funda-ui",
|
|
5
|
-
"version": "4.6.
|
|
5
|
+
"version": "4.6.222",
|
|
6
6
|
"description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|