This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
assets/javascripts/discourse/components/modal Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,21 @@ class AiArtifact < ActiveRecord::Base
1818 https://code.jquery.com
1919 ]
2020
21+ def self . artifact_version_attribute ( version )
22+ if version
23+ "data-artifact-version='#{ version } '"
24+ else
25+ ""
26+ end
27+ end
28+
2129 def self . iframe_for ( id , version = nil )
2230 <<~HTML
2331 < div class ='ai-artifact '>
2432 < iframe src ='#{ url ( id , version ) } ' frameborder="0" height="100%" width="100%"> </ iframe>
2533 < div class ='ai-artifact-controls '>
2634 < a href ='#{ url ( id , version ) } ' class='link-artifact' target='_blank'> #{ I18n . t ( "discourse_ai.ai_artifact.link" ) } </ a>
27- < a href class ='copy-embed ' data-url ="#{ url ( id , version ) } "> #{ I18n . t ( "discourse_ai.ai_artifact.copy_embed" ) } </ a>
35+ < a href class ='copy-embed ' data-artifact-id =" #{ id } " #{ artifact_version_attribute ( version ) } data- url="#{ url ( id , version ) } "> #{ I18n . t ( "discourse_ai.ai_artifact.copy_embed" ) } </ a>
2836 </ div>
2937 </ div>
3038 HTML
Original file line number Diff line number Diff line change @@ -96,9 +96,14 @@ export default class ShareModal extends Component {
9696 }
9797 event .stopPropagation ();
9898 event .preventDefault ();
99- const iframeEmbed = ` <iframe src="${ event .target .dataset .url } " width="600px" height="600px" frameborder="0"></iframe>` ;
99+
100+ let version = " " ;
101+ if (event .target .dataset .artifactVersion ) {
102+ version = ` data-ai-artifact-version="${ event .target .dataset .artifactVersion } "` ;
103+ }
104+ const artifactEmbed = ` <div class="ai-artifact" ${ version} data-ai-artifact-id="${ event .target .dataset .artifactId } "></div>` ;
100105 const promise = new Promise ((resolve ) => {
101- resolve (iframeEmbed );
106+ resolve (artifactEmbed );
102107 });
103108
104109 await clipboardCopyAsync (() => promise);
You can’t perform that action at this time.
0 commit comments