@convai/web-sdk 1.9.0-beta.0 → 1.9.0-beta.1
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/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/embed/chat-embed-v1.js +1 -1
- package/dist/embed/chat-embed-v1.js.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +14 -3
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +110 -130
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +1 -1
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/utils/lightbox.d.ts +16 -0
- package/dist/utils/lightbox.d.ts.map +1 -0
- package/dist/utils/lightbox.js +95 -0
- package/dist/utils/lightbox.js.map +1 -0
- package/dist/utils/linkPresentation.d.ts +69 -0
- package/dist/utils/linkPresentation.d.ts.map +1 -0
- package/dist/utils/linkPresentation.js +358 -0
- package/dist/utils/linkPresentation.js.map +1 -0
- package/dist/vanilla/ConvaiWidget.d.ts.map +1 -1
- package/dist/vanilla/ConvaiWidget.js +216 -189
- package/dist/vanilla/ConvaiWidget.js.map +1 -1
- package/dist/vanilla/index.d.ts +2 -0
- package/dist/vanilla/index.d.ts.map +1 -1
- package/dist/vanilla/index.js +1 -0
- package/dist/vanilla/index.js.map +1 -1
- package/dist/vanilla/styles.d.ts.map +1 -1
- package/dist/vanilla/styles.js +9 -0
- package/dist/vanilla/styles.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
|
@@ -8,6 +8,8 @@ import { Icons } from "./icons.js";
|
|
|
8
8
|
import { WidgetEventSubscriptions } from "./WidgetEventSubscriptions.js";
|
|
9
9
|
import { ConvaiClient } from "../core/ConvaiClient.js";
|
|
10
10
|
import { parseInlineMarkdown, compactUrl } from "../utils/inlineMarkdown.js";
|
|
11
|
+
import { linkKindForUrl, describeUrl, fileNameOf, documentBadge, contactLabel, hoverTitle, isMixedContent, glyph, presentationStyles as S, toCssText, PREVIEW_TIMEOUT_MS, MAX_CARDS_PER_MESSAGE, } from "../utils/linkPresentation.js";
|
|
12
|
+
import { openLightbox } from "../utils/lightbox.js";
|
|
11
13
|
import { freshPublicationGrantOptions } from "../core/publishedChat.js";
|
|
12
14
|
/**
|
|
13
15
|
* Positioning declarations for the widget root, keyed by `placement`. The
|
|
@@ -2074,217 +2076,242 @@ export function createConvaiWidget(container, options) {
|
|
|
2074
2076
|
});
|
|
2075
2077
|
};
|
|
2076
2078
|
// Microphone button removed - only controlled via voice mode now
|
|
2077
|
-
//
|
|
2078
|
-
//
|
|
2079
|
-
//
|
|
2080
|
-
//
|
|
2081
|
-
//
|
|
2079
|
+
// The bubble renderer. Everything visual comes from utils/linkPresentation
|
|
2080
|
+
// so this and the React MarkdownRenderer cannot drift; this only maps
|
|
2081
|
+
// tokenizer nodes onto DOM. `media` gates cards and chips: bot bubbles get
|
|
2082
|
+
// them, the user's own bubble keeps anchors only, so a pasted URL never
|
|
2083
|
+
// pulls remote media into the transcript.
|
|
2082
2084
|
const renderMarkdown = (text, container, { media = true } = {}) => {
|
|
2083
2085
|
if (!text)
|
|
2084
2086
|
return;
|
|
2085
|
-
// Handle both actual newlines and \n
|
|
2086
|
-
const
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2087
|
+
// Handle both actual newlines and literal "\n" sequences.
|
|
2088
|
+
const lines = text.replace(/\\n/g, "\n").split("\n");
|
|
2089
|
+
// Cards drawn so far in this message, against MAX_CARDS_PER_MESSAGE.
|
|
2090
|
+
const budget = { cards: 0 };
|
|
2091
|
+
const make = (tag, part, ...styles) => {
|
|
2092
|
+
const node = document.createElement(tag);
|
|
2093
|
+
node.setAttribute("part", part);
|
|
2094
|
+
node.style.cssText = toCssText(Object.assign({}, ...styles));
|
|
2095
|
+
return node;
|
|
2096
|
+
};
|
|
2097
|
+
// Inline styles cannot express :focus-visible, so the ring is toggled by hand.
|
|
2098
|
+
const focusRing = (node) => {
|
|
2099
|
+
const base = node.style.cssText;
|
|
2100
|
+
node.addEventListener("focus", () => {
|
|
2101
|
+
if (node.matches(":focus-visible"))
|
|
2102
|
+
node.style.cssText = `${base} ${toCssText(S.linkFocus)}`;
|
|
2103
|
+
});
|
|
2104
|
+
node.addEventListener("blur", () => {
|
|
2105
|
+
node.style.cssText = base;
|
|
2106
|
+
});
|
|
2107
|
+
};
|
|
2108
|
+
const anchor = (href, kind, label) => {
|
|
2109
|
+
const a = make("a", "message-link", S.link);
|
|
2110
|
+
a.href = href;
|
|
2111
|
+
a.target = "_blank";
|
|
2112
|
+
a.rel = "noopener noreferrer";
|
|
2113
|
+
// A bare URL is its own label and may be elided for display; the title
|
|
2114
|
+
// compares against what is shown so the full target is one hover away.
|
|
2115
|
+
const display = label === href ? compactUrl(label) : label;
|
|
2116
|
+
a.textContent = display;
|
|
2117
|
+
const title = hoverTitle(kind, href, display);
|
|
2118
|
+
if (title)
|
|
2119
|
+
a.title = title;
|
|
2120
|
+
if (kind === "ftp") {
|
|
2121
|
+
const badge = make("span", "message-link-badge", S.badge);
|
|
2122
|
+
badge.textContent = "FTP";
|
|
2123
|
+
a.appendChild(badge);
|
|
2124
|
+
}
|
|
2125
|
+
focusRing(a);
|
|
2126
|
+
return a;
|
|
2127
|
+
};
|
|
2128
|
+
const contactChip = (href, kind) => {
|
|
2129
|
+
const a = make("a", "message-contact", S.contact);
|
|
2130
|
+
a.href = href;
|
|
2131
|
+
a.title = hoverTitle(kind, href, href);
|
|
2132
|
+
const g = make("span", "message-contact-glyph", S.contactGlyph);
|
|
2133
|
+
g.innerHTML = glyph(kind);
|
|
2134
|
+
const t = document.createElement("span");
|
|
2135
|
+
t.textContent = contactLabel(href);
|
|
2136
|
+
a.append(g, t);
|
|
2137
|
+
focusRing(a);
|
|
2138
|
+
return a;
|
|
2139
|
+
};
|
|
2140
|
+
const documentCard = (href) => {
|
|
2141
|
+
let host = "";
|
|
2142
|
+
try {
|
|
2143
|
+
host = new URL(href).host;
|
|
2144
|
+
}
|
|
2145
|
+
catch {
|
|
2146
|
+
/* keep empty */
|
|
2147
|
+
}
|
|
2148
|
+
const a = make("a", "message-file-card", S.fileCard);
|
|
2149
|
+
a.href = href;
|
|
2150
|
+
a.target = "_blank";
|
|
2151
|
+
a.rel = "noopener noreferrer";
|
|
2152
|
+
a.title = href;
|
|
2153
|
+
const icon = make("span", "message-file-icon", S.fileIcon);
|
|
2154
|
+
icon.textContent = documentBadge(href);
|
|
2155
|
+
const body = document.createElement("span");
|
|
2156
|
+
body.style.cssText = toCssText(S.fileBody);
|
|
2157
|
+
const name = make("span", "message-file-name", S.fileName);
|
|
2158
|
+
name.textContent = fileNameOf(href);
|
|
2159
|
+
const meta = make("span", "message-file-meta", S.fileMeta);
|
|
2160
|
+
meta.textContent = `${host} · Opens in a new tab`;
|
|
2161
|
+
body.append(name, meta);
|
|
2162
|
+
a.append(icon, body);
|
|
2163
|
+
focusRing(a);
|
|
2164
|
+
return a;
|
|
2165
|
+
};
|
|
2166
|
+
const unavailable = (src, insecure) => {
|
|
2167
|
+
const dead = make("span", "message-media-unavailable", S.unavailable);
|
|
2168
|
+
dead.textContent = `Preview unavailable — ${describeUrl(src)}${insecure ? " (insecure URL)" : ""}`;
|
|
2169
|
+
return dead;
|
|
2170
|
+
};
|
|
2171
|
+
/**
|
|
2172
|
+
* Image or video card. The element is created up front so the fetch starts
|
|
2173
|
+
* immediately; a skeleton covers it until it decodes. Error, timeout, or an
|
|
2174
|
+
* insecure URL collapse the card to one muted line — a character can
|
|
2175
|
+
* invent a URL, and an empty player in the transcript reads as a broken
|
|
2176
|
+
* widget.
|
|
2177
|
+
*/
|
|
2178
|
+
const mediaPreview = (src, alt, kind) => {
|
|
2179
|
+
const frag = document.createDocumentFragment();
|
|
2180
|
+
if (isMixedContent(src)) {
|
|
2181
|
+
frag.appendChild(unavailable(src, true));
|
|
2182
|
+
return frag;
|
|
2183
|
+
}
|
|
2184
|
+
const card = make("span", "message-media-card", S.card, kind === "image" ? S.cardButton : {});
|
|
2185
|
+
const el = kind === "image"
|
|
2186
|
+
? Object.assign(document.createElement("img"), { src, alt, loading: "lazy" })
|
|
2187
|
+
: Object.assign(document.createElement("video"), { src, controls: true, preload: "metadata" });
|
|
2188
|
+
el.setAttribute("part", "message-media");
|
|
2189
|
+
el.style.cssText = toCssText(Object.assign({}, S.media, kind === "video" ? S.videoMedia : {}, { opacity: 0 }));
|
|
2190
|
+
const skeleton = make("span", "message-media-skeleton", S.skeleton);
|
|
2191
|
+
skeleton.setAttribute("aria-hidden", "true");
|
|
2192
|
+
skeleton.dataset.convaiSkeleton = "";
|
|
2193
|
+
const caption = make("span", "message-media-caption", S.caption);
|
|
2194
|
+
caption.textContent = describeUrl(src);
|
|
2195
|
+
const fail = () => {
|
|
2196
|
+
clearTimeout(timer);
|
|
2197
|
+
card.replaceWith(unavailable(src, false));
|
|
2198
|
+
caption.remove();
|
|
2199
|
+
};
|
|
2200
|
+
const settled = () => {
|
|
2201
|
+
clearTimeout(timer);
|
|
2202
|
+
el.style.opacity = "1";
|
|
2203
|
+
skeleton.remove();
|
|
2204
|
+
if (kind === "image") {
|
|
2205
|
+
const zoom = make("span", "message-media-zoom", S.zoom);
|
|
2206
|
+
zoom.innerHTML = glyph("zoom");
|
|
2207
|
+
card.appendChild(zoom);
|
|
2100
2208
|
}
|
|
2101
2209
|
};
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
position: relative;
|
|
2117
|
-
margin-top: 6px;
|
|
2118
|
-
max-width: 320px;
|
|
2119
|
-
aspect-ratio: 16 / 10;
|
|
2120
|
-
border-radius: 8px;
|
|
2121
|
-
overflow: hidden;
|
|
2122
|
-
background: color-mix(in srgb, currentColor 6%, transparent);
|
|
2123
|
-
box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 10%, transparent);
|
|
2124
|
-
`;
|
|
2125
|
-
const el = media === "image"
|
|
2126
|
-
? Object.assign(document.createElement("img"), { src, alt, loading: "lazy" })
|
|
2127
|
-
: Object.assign(document.createElement("video"), { src, controls: true, preload: "metadata" });
|
|
2128
|
-
el.setAttribute("part", "message-media");
|
|
2129
|
-
el.style.cssText = `
|
|
2130
|
-
display: block;
|
|
2131
|
-
width: 100%;
|
|
2132
|
-
height: 100%;
|
|
2133
|
-
object-fit: ${media === "image" ? "cover" : "contain"};
|
|
2134
|
-
border-radius: 8px;
|
|
2135
|
-
opacity: 0;
|
|
2136
|
-
transition: opacity .18s ease;
|
|
2137
|
-
`;
|
|
2138
|
-
const skeleton = document.createElement("span");
|
|
2139
|
-
skeleton.setAttribute("part", "message-media-skeleton");
|
|
2140
|
-
skeleton.setAttribute("aria-hidden", "true");
|
|
2141
|
-
skeleton.dataset.convaiSkeleton = "";
|
|
2142
|
-
skeleton.style.cssText = `
|
|
2143
|
-
position: absolute;
|
|
2144
|
-
inset: 0;
|
|
2145
|
-
border-radius: 8px;
|
|
2146
|
-
background: color-mix(in srgb, currentColor 8%, transparent);
|
|
2147
|
-
background-image: linear-gradient(90deg, transparent, color-mix(in srgb, currentColor 12%, transparent), transparent);
|
|
2148
|
-
background-size: 200% 100%;
|
|
2149
|
-
animation: convai-preview-shimmer 1.4s ease-in-out infinite;
|
|
2150
|
-
`;
|
|
2151
|
-
const caption = document.createElement("span");
|
|
2152
|
-
caption.setAttribute("part", "message-media-caption");
|
|
2153
|
-
caption.textContent = describeUrl(src);
|
|
2154
|
-
caption.style.cssText = `
|
|
2155
|
-
display: block;
|
|
2156
|
-
margin-top: 4px;
|
|
2157
|
-
font-size: 11px;
|
|
2158
|
-
opacity: .7;
|
|
2159
|
-
white-space: nowrap;
|
|
2160
|
-
overflow: hidden;
|
|
2161
|
-
text-overflow: ellipsis;
|
|
2162
|
-
`;
|
|
2163
|
-
const settled = () => {
|
|
2164
|
-
el.style.opacity = "1";
|
|
2165
|
-
skeleton.remove();
|
|
2166
|
-
};
|
|
2167
|
-
el.addEventListener(media === "image" ? "load" : "loadedmetadata", settled);
|
|
2168
|
-
el.addEventListener("error", () => {
|
|
2169
|
-
const dead = document.createElement("span");
|
|
2170
|
-
dead.setAttribute("part", "message-media-unavailable");
|
|
2171
|
-
dead.textContent = `Preview unavailable — ${describeUrl(src)}`;
|
|
2172
|
-
dead.style.cssText = `
|
|
2173
|
-
display: block;
|
|
2174
|
-
margin-top: 6px;
|
|
2175
|
-
font-size: 11px;
|
|
2176
|
-
opacity: .55;
|
|
2177
|
-
font-style: italic;
|
|
2178
|
-
white-space: nowrap;
|
|
2179
|
-
overflow: hidden;
|
|
2180
|
-
text-overflow: ellipsis;
|
|
2181
|
-
`;
|
|
2182
|
-
card.replaceWith(dead);
|
|
2183
|
-
caption.remove();
|
|
2210
|
+
const timer = setTimeout(fail, PREVIEW_TIMEOUT_MS);
|
|
2211
|
+
el.addEventListener(kind === "image" ? "load" : "loadedmetadata", settled);
|
|
2212
|
+
el.addEventListener("error", fail);
|
|
2213
|
+
if (kind === "image") {
|
|
2214
|
+
card.setAttribute("role", "button");
|
|
2215
|
+
card.tabIndex = 0;
|
|
2216
|
+
card.setAttribute("aria-label", `Open image: ${fileNameOf(src)}`);
|
|
2217
|
+
const open = () => openLightbox({
|
|
2218
|
+
src,
|
|
2219
|
+
alt,
|
|
2220
|
+
caption: describeUrl(src),
|
|
2221
|
+
href: src,
|
|
2222
|
+
root: styleTarget,
|
|
2223
|
+
returnFocusTo: card,
|
|
2184
2224
|
});
|
|
2185
|
-
card.
|
|
2186
|
-
card.
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2225
|
+
card.addEventListener("click", open);
|
|
2226
|
+
card.addEventListener("keydown", (e) => {
|
|
2227
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2228
|
+
e.preventDefault();
|
|
2229
|
+
open();
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
card.append(el, skeleton);
|
|
2234
|
+
frag.append(card, caption);
|
|
2235
|
+
return frag;
|
|
2236
|
+
};
|
|
2237
|
+
const processLine = (line) => {
|
|
2238
|
+
const parts = [];
|
|
2239
|
+
for (const node of parseInlineMarkdown(line)) {
|
|
2240
|
+
switch (node.kind) {
|
|
2241
|
+
case "strong": {
|
|
2242
|
+
// matches React UserBubble styling
|
|
2243
|
+
const strong = document.createElement("strong");
|
|
2244
|
+
strong.textContent = node.text;
|
|
2245
|
+
strong.style.cssText = `
|
|
2201
2246
|
font-weight: 600;
|
|
2202
2247
|
color: var(--convai-panel-fg, ${aeroTheme.colors.text.primary});
|
|
2203
2248
|
`;
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2249
|
+
parts.push(strong);
|
|
2250
|
+
break;
|
|
2251
|
+
}
|
|
2252
|
+
case "em": {
|
|
2253
|
+
const em = document.createElement("em");
|
|
2254
|
+
em.textContent = node.text;
|
|
2255
|
+
em.style.cssText = `font-style: italic;`;
|
|
2256
|
+
parts.push(em);
|
|
2257
|
+
break;
|
|
2258
|
+
}
|
|
2259
|
+
case "blocked": {
|
|
2260
|
+
// Not an anchor, ever. The label reads as the character wrote it;
|
|
2261
|
+
// the target is only revealed on hover.
|
|
2262
|
+
const blocked = make("span", "message-link-blocked", S.blocked);
|
|
2263
|
+
blocked.textContent = node.label;
|
|
2264
|
+
blocked.title = `Link blocked: ${node.href}`;
|
|
2265
|
+
parts.push(blocked);
|
|
2266
|
+
break;
|
|
2267
|
+
}
|
|
2268
|
+
case "image": {
|
|
2269
|
+
if (media && budget.cards < MAX_CARDS_PER_MESSAGE) {
|
|
2270
|
+
budget.cards++;
|
|
2271
|
+
parts.push(mediaPreview(node.src, node.alt, "image"));
|
|
2213
2272
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
a
|
|
2217
|
-
|
|
2218
|
-
a.target = "_blank";
|
|
2219
|
-
a.rel = "noopener noreferrer";
|
|
2220
|
-
a.setAttribute("part", "message-link");
|
|
2221
|
-
a.style.cssText = `
|
|
2222
|
-
color: #10b981;
|
|
2223
|
-
text-decoration: underline;
|
|
2224
|
-
word-break: break-all;
|
|
2225
|
-
`;
|
|
2226
|
-
parts.push(a);
|
|
2227
|
-
if (media && node.media)
|
|
2228
|
-
parts.push(mediaPreview(node.href, node.label, node.media));
|
|
2229
|
-
break;
|
|
2273
|
+
else {
|
|
2274
|
+
// With previews off (or the budget spent), an image still has to
|
|
2275
|
+
// say what it pointed at, so it degrades to a plain anchor.
|
|
2276
|
+
parts.push(anchor(node.src, "image", node.alt || node.src));
|
|
2230
2277
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
opacity: .75;
|
|
2238
|
-
text-decoration: underline dotted;
|
|
2239
|
-
cursor: help;
|
|
2240
|
-
`;
|
|
2241
|
-
parts.push(blocked);
|
|
2278
|
+
break;
|
|
2279
|
+
}
|
|
2280
|
+
case "link": {
|
|
2281
|
+
const kind = linkKindForUrl(node.href);
|
|
2282
|
+
if (kind === "email" || kind === "phone" || kind === "sms") {
|
|
2283
|
+
parts.push(media ? contactChip(node.href, kind) : anchor(node.href, kind, node.label));
|
|
2242
2284
|
break;
|
|
2243
2285
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
// With previews off, an image still has to say what it pointed at,
|
|
2250
|
-
// so it degrades to the same anchor a plain link would render.
|
|
2251
|
-
const imgLink = document.createElement("a");
|
|
2252
|
-
imgLink.href = node.src;
|
|
2253
|
-
imgLink.textContent = node.alt || node.src;
|
|
2254
|
-
imgLink.target = "_blank";
|
|
2255
|
-
imgLink.rel = "noopener noreferrer";
|
|
2256
|
-
imgLink.setAttribute("part", "message-link");
|
|
2257
|
-
imgLink.style.cssText = `
|
|
2258
|
-
color: #10b981;
|
|
2259
|
-
text-decoration: underline;
|
|
2260
|
-
word-break: break-all;
|
|
2261
|
-
`;
|
|
2262
|
-
parts.push(imgLink);
|
|
2286
|
+
parts.push(anchor(node.href, kind, node.label));
|
|
2287
|
+
const wantsCard = media &&
|
|
2288
|
+
(kind === "image" || kind === "video" || kind === "document") &&
|
|
2289
|
+
budget.cards < MAX_CARDS_PER_MESSAGE;
|
|
2290
|
+
if (!wantsCard)
|
|
2263
2291
|
break;
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2292
|
+
budget.cards++;
|
|
2293
|
+
parts.push(kind === "document" ? documentCard(node.href) : mediaPreview(node.href, node.label, kind));
|
|
2294
|
+
break;
|
|
2267
2295
|
}
|
|
2296
|
+
default:
|
|
2297
|
+
parts.push(document.createTextNode(node.text));
|
|
2268
2298
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2299
|
+
}
|
|
2300
|
+
return parts;
|
|
2301
|
+
};
|
|
2302
|
+
lines.forEach((line, lineIndex) => {
|
|
2303
|
+
// An empty line is paragraph spacing.
|
|
2273
2304
|
if (line.trim() === "" && lineIndex > 0) {
|
|
2274
2305
|
container.appendChild(document.createElement("br"));
|
|
2275
2306
|
return;
|
|
2276
2307
|
}
|
|
2277
|
-
|
|
2278
|
-
if (
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
else {
|
|
2308
|
+
const processed = processLine(line);
|
|
2309
|
+
if (processed.length > 0)
|
|
2310
|
+
processed.forEach((p) => container.appendChild(p));
|
|
2311
|
+
else
|
|
2282
2312
|
container.appendChild(document.createTextNode(line));
|
|
2283
|
-
|
|
2284
|
-
// Add line break between lines
|
|
2285
|
-
if (lineIndex < lines.length - 1) {
|
|
2313
|
+
if (lineIndex < lines.length - 1)
|
|
2286
2314
|
container.appendChild(document.createElement("br"));
|
|
2287
|
-
}
|
|
2288
2315
|
});
|
|
2289
2316
|
};
|
|
2290
2317
|
const updateMessageList = () => {
|