Add auto-reload for HTML artifacts when dependencies change
HTML artifacts can read other artifacts via getArtifact() and attachments. When any artifact is created, updated, rewritten, or deleted, all HTML artifacts now automatically reload to reflect the latest data. Changes: - Add reloadAllHtmlArtifacts() method to ArtifactsPanel - Call reload after all artifact mutations (create/update/rewrite/delete) - Make HtmlArtifact.sandboxIframeRef and executeContent() public - Update runtime providers before re-executing HTML content This ensures HTML artifacts always display current data from their dependencies.
This commit is contained in:
@@ -23,7 +23,7 @@ export class HtmlArtifact extends ArtifactElement {
|
||||
private logs: Array<{ type: "log" | "error"; text: string }> = [];
|
||||
|
||||
// Refs for DOM elements
|
||||
private sandboxIframeRef: Ref<SandboxIframe> = createRef();
|
||||
public sandboxIframeRef: Ref<SandboxIframe> = createRef();
|
||||
private consoleRef: Ref<Console> = createRef();
|
||||
|
||||
@state() private viewMode: "preview" | "code" = "preview";
|
||||
@@ -76,7 +76,7 @@ export class HtmlArtifact extends ArtifactElement {
|
||||
}
|
||||
}
|
||||
|
||||
private executeContent(html: string) {
|
||||
public executeContent(html: string) {
|
||||
const sandbox = this.sandboxIframeRef.value;
|
||||
if (!sandbox) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user