might as well use the local format when in the share dialog
This commit is contained in:
parent
6b57e3e053
commit
7e873f4a77
|
@ -18,13 +18,21 @@ class AiArtifact < ActiveRecord::Base
|
||||||
https://code.jquery.com
|
https://code.jquery.com
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def self.artifact_version_attribute(version)
|
||||||
|
if version
|
||||||
|
"data-artifact-version='#{version}'"
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.iframe_for(id, version = nil)
|
def self.iframe_for(id, version = nil)
|
||||||
<<~HTML
|
<<~HTML
|
||||||
<div class='ai-artifact'>
|
<div class='ai-artifact'>
|
||||||
<iframe src='#{url(id, version)}' frameborder="0" height="100%" width="100%"></iframe>
|
<iframe src='#{url(id, version)}' frameborder="0" height="100%" width="100%"></iframe>
|
||||||
<div class='ai-artifact-controls'>
|
<div class='ai-artifact-controls'>
|
||||||
<a href='#{url(id, version)}' class='link-artifact' target='_blank'>#{I18n.t("discourse_ai.ai_artifact.link")}</a>
|
<a href='#{url(id, version)}' class='link-artifact' target='_blank'>#{I18n.t("discourse_ai.ai_artifact.link")}</a>
|
||||||
<a href class='copy-embed' data-url="#{url(id, version)}">#{I18n.t("discourse_ai.ai_artifact.copy_embed")}</a>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
HTML
|
HTML
|
||||||
|
|
|
@ -96,9 +96,14 @@ export default class ShareModal extends Component {
|
||||||
}
|
}
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const iframeEmbed = `<iframe src="${event.target.dataset.url}" width="600px" height="600px" frameborder="0"></iframe>`;
|
|
||||||
|
let version = "";
|
||||||
|
if (event.target.dataset.artifactVersion) {
|
||||||
|
version = `data-ai-artifact-version="${event.target.dataset.artifactVersion}"`;
|
||||||
|
}
|
||||||
|
const artifactEmbed = `<div class="ai-artifact" ${version} data-ai-artifact-id="${event.target.dataset.artifactId}"></div>`;
|
||||||
const promise = new Promise((resolve) => {
|
const promise = new Promise((resolve) => {
|
||||||
resolve(iframeEmbed);
|
resolve(artifactEmbed);
|
||||||
});
|
});
|
||||||
|
|
||||||
await clipboardCopyAsync(() => promise);
|
await clipboardCopyAsync(() => promise);
|
||||||
|
|
Loading…
Reference in New Issue