UX: improve artifact styling add direct share link (#930)

Also remove uneeded sandboxing give this is all handled by
artifacts directly
This commit is contained in:
Sam 2024-11-20 13:13:03 +11:00 committed by GitHub
parent a0aec48606
commit 2652716398
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 13 deletions

View File

@ -52,6 +52,11 @@ module DiscourseAi
padding: 0; padding: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
border: 0;
overflow: hidden;
}
iframe {
overflow: auto;
} }
</style> </style>
</head> </head>

View File

@ -9,7 +9,10 @@ class AiArtifact < ActiveRecord::Base
def self.iframe_for(id) def self.iframe_for(id)
<<~HTML <<~HTML
<iframe sandbox="allow-scripts allow-forms" height="600px" src='#{url(id)}' frameborder="0" width="100%"></iframe> <div class='ai-artifact'>
<iframe src='#{url(id)}' frameborder="0" height="100%" width="100%"></iframe>
<a href='#{url(id)}' target='_blank'>#{I18n.t("discourse_ai.ai_artifact.link")}</a>
</div>
HTML HTML
end end

View File

@ -104,7 +104,6 @@ export default class AiArtifactComponent extends Component {
src={{this.artifactUrl}} src={{this.artifactUrl}}
width="100%" width="100%"
frameborder="0" frameborder="0"
sandbox="allow-scripts allow-forms"
></iframe> ></iframe>
{{/if}} {{/if}}
{{#unless this.requireClickToRun}} {{#unless this.requireClickToRun}}

View File

@ -173,6 +173,8 @@ en:
title: Surprise title: Surprise
discourse_ai: discourse_ai:
ai_artifact:
link: "Show Artifact in new tab"
unknown_model: "Unknown AI model" unknown_model: "Unknown AI model"
tools: tools:

View File

@ -627,3 +627,8 @@ aside.onebox h3 {
opacity: 0.85; opacity: 0.85;
transition: opacity 0.25s ease-in-out; transition: opacity 0.25s ease-in-out;
} }
.ai-artifact iframe {
height: 600px;
max-height: 600px;
}