fix(web): open artifacts outside the installed app context
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
// slash commands, notices and the local rename/hide/seen store. Pure models live
|
||||
// in chat.js and markdown.js; this module owns the DOM and the chat wire wiring.
|
||||
|
||||
import { backChevronIcon, h } from "../dom.js";
|
||||
import { backChevronIcon, h, artifactBrowserLinkProps } from "../dom.js";
|
||||
import { isLocalArtifactLink } from "../artifactNavigation.js";
|
||||
import { formFieldVisible, formFieldValue, formAnswerError, visibleFormAnswers, safeFormURL } from "../chatForms.js";
|
||||
import { readChatStars, writeChatStars } from "../chatStars.js";
|
||||
import { chatModelLabel, chatModelSelectionNote, supportsChatModels } from "../chatModels.js";
|
||||
@@ -3795,13 +3796,17 @@ function renderInlineNodes(spans) {
|
||||
if (span.kind === "strong") return h("strong", {}, ...renderInlineNodes(span.spans));
|
||||
if (span.kind === "emphasis") return h("em", {}, ...renderInlineNodes(span.spans));
|
||||
if (span.kind === "link") {
|
||||
// Only http(s) targets become links: the transcript is untrusted model
|
||||
// Only HTTP(S) or validated same-origin artifact targets become links:
|
||||
// the transcript is untrusted model
|
||||
// output, so a javascript:/data: target is shown as its label, never made
|
||||
// clickable. Nothing is dropped either way.
|
||||
if (/^https?:\/\//i.test(span.url)) {
|
||||
const artifact = isLocalArtifactLink(span.url, globalThis.location?.href);
|
||||
const linkProps = artifact ? artifactBrowserLinkProps(span.url)
|
||||
: /^https?:\/\//i.test(span.url) ? { href: span.url, rel: "noreferrer noopener", target: "_blank" } : null;
|
||||
if (linkProps) {
|
||||
return h(
|
||||
"a",
|
||||
{ class: "md-link", href: span.url, rel: "noreferrer noopener", target: "_blank" },
|
||||
{ class: "md-link", ...linkProps },
|
||||
...renderInlineNodes(span.spans),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user