llmasaservice-ui 0.3.10 → 0.3.12
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/index.js +5 -5
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- package/src/ChatPanel.tsx +10 -9
package/dist/index.js
CHANGED
|
@@ -125,11 +125,9 @@ var ChatPanel = ({
|
|
|
125
125
|
const buttonId = `button-${index}-${matchIndex}`;
|
|
126
126
|
let html = match;
|
|
127
127
|
if (action.type === "button" || action.type === "callback") {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
} else if (action.type === "markdown") {
|
|
128
|
+
console.log("Creating button", buttonId, action);
|
|
129
|
+
html = `<button id="${buttonId}">${(_a = action.markdown) != null ? _a : match}</button>`;
|
|
130
|
+
} else if (action.type === "markdown" || action.type === "html") {
|
|
133
131
|
html = (_b = action.markdown) != null ? _b : "";
|
|
134
132
|
}
|
|
135
133
|
html = html.replace(new RegExp("\\$match", "g"), match);
|
|
@@ -140,6 +138,7 @@ var ChatPanel = ({
|
|
|
140
138
|
const button = document.getElementById(buttonId);
|
|
141
139
|
if (button) {
|
|
142
140
|
if (!button.onclick) {
|
|
141
|
+
console.log("Setting button click event", buttonId, action);
|
|
143
142
|
button.onclick = () => {
|
|
144
143
|
if (action.callback) {
|
|
145
144
|
action.callback(match, groups);
|
|
@@ -156,6 +155,7 @@ var ChatPanel = ({
|
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
}, 0);
|
|
158
|
+
console.log("html", html);
|
|
159
159
|
return html;
|
|
160
160
|
});
|
|
161
161
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -92,11 +92,9 @@ var ChatPanel = ({
|
|
|
92
92
|
const buttonId = `button-${index}-${matchIndex}`;
|
|
93
93
|
let html = match;
|
|
94
94
|
if (action.type === "button" || action.type === "callback") {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
} else if (action.type === "markdown") {
|
|
95
|
+
console.log("Creating button", buttonId, action);
|
|
96
|
+
html = `<button id="${buttonId}">${(_a = action.markdown) != null ? _a : match}</button>`;
|
|
97
|
+
} else if (action.type === "markdown" || action.type === "html") {
|
|
100
98
|
html = (_b = action.markdown) != null ? _b : "";
|
|
101
99
|
}
|
|
102
100
|
html = html.replace(new RegExp("\\$match", "g"), match);
|
|
@@ -107,6 +105,7 @@ var ChatPanel = ({
|
|
|
107
105
|
const button = document.getElementById(buttonId);
|
|
108
106
|
if (button) {
|
|
109
107
|
if (!button.onclick) {
|
|
108
|
+
console.log("Setting button click event", buttonId, action);
|
|
110
109
|
button.onclick = () => {
|
|
111
110
|
if (action.callback) {
|
|
112
111
|
action.callback(match, groups);
|
|
@@ -123,6 +122,7 @@ var ChatPanel = ({
|
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
124
|
}, 0);
|
|
125
|
+
console.log("html", html);
|
|
126
126
|
return html;
|
|
127
127
|
});
|
|
128
128
|
});
|
package/package.json
CHANGED
package/src/ChatPanel.tsx
CHANGED
|
@@ -120,33 +120,32 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
120
120
|
actions.forEach((action, index) => {
|
|
121
121
|
const regex = new RegExp(action.pattern, "gmi");
|
|
122
122
|
newResponse = newResponse.replace(regex, (match, ...groups) => {
|
|
123
|
-
|
|
124
123
|
console.log("match", match);
|
|
125
124
|
console.log("groups", groups);
|
|
126
125
|
|
|
127
126
|
const matchIndex = groups[groups.length - 2]; // The second-to-last argument is the match index
|
|
128
|
-
|
|
129
127
|
const buttonId = `button-${index}-${matchIndex}`;
|
|
130
128
|
|
|
131
129
|
let html = match;
|
|
132
130
|
if (action.type === "button" || action.type === "callback") {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
} else if (action.type === "markdown") {
|
|
131
|
+
console.log("Creating button", buttonId, action);
|
|
132
|
+
html = `<button id="${buttonId}">${
|
|
133
|
+
action.markdown ?? match
|
|
134
|
+
}</button>`;
|
|
135
|
+
} else if (action.type === "markdown" || action.type === "html") {
|
|
138
136
|
html = action.markdown ?? "";
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
html = html.replace(new RegExp("\\$match", "g"), match);
|
|
142
140
|
groups.forEach((group, index) => {
|
|
143
|
-
html = html.replace(new RegExp(`\\$${index + 1}`,
|
|
141
|
+
html = html.replace(new RegExp(`\\$${index + 1}`, "g"), group);
|
|
144
142
|
});
|
|
145
143
|
|
|
146
144
|
setTimeout(() => {
|
|
147
145
|
const button = document.getElementById(buttonId);
|
|
148
146
|
if (button) {
|
|
149
147
|
if (!button.onclick) {
|
|
148
|
+
console.log("Setting button click event", buttonId, action);
|
|
150
149
|
button.onclick = () => {
|
|
151
150
|
if (action.callback) {
|
|
152
151
|
action.callback(match, groups);
|
|
@@ -163,6 +162,8 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
}, 0);
|
|
165
|
+
|
|
166
|
+
console.log("html", html);
|
|
166
167
|
return html;
|
|
167
168
|
});
|
|
168
169
|
});
|
|
@@ -390,7 +391,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
390
391
|
</a>
|
|
391
392
|
);
|
|
392
393
|
};
|
|
393
|
-
|
|
394
|
+
|
|
394
395
|
return (
|
|
395
396
|
<>
|
|
396
397
|
<div
|