mirror of
https://github.com/cyclotruc/gitingest.git
synced 2026-04-28 15:49:31 +00:00
Add copy whole digest button
This commit is contained in:
parent
e3e8880ffe
commit
49790d39a0
2 changed files with 37 additions and 1 deletions
|
|
@ -87,6 +87,29 @@ function handleSubmit(event, showLoading = false) {
|
|||
});
|
||||
}
|
||||
|
||||
function copyFullDigest() {
|
||||
const directoryStructure = document.querySelector('.directory-structure').value;
|
||||
const filesContent = document.querySelector('.result-text').value;
|
||||
const fullDigest = `Directory Structure:\n\n${directoryStructure}\n\nFiles Content:\n\n${filesContent}`;
|
||||
const button = document.querySelector('[onclick="copyFullDigest()"]');
|
||||
const originalText = button.innerHTML;
|
||||
|
||||
navigator.clipboard.writeText(fullDigest).then(() => {
|
||||
button.innerHTML = `
|
||||
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
|
||||
</svg>
|
||||
Copied!
|
||||
`;
|
||||
|
||||
setTimeout(() => {
|
||||
button.innerHTML = originalText;
|
||||
}, 2000);
|
||||
}).catch(err => {
|
||||
console.error('Failed to copy text: ', err);
|
||||
});
|
||||
}
|
||||
|
||||
// Export functions if using modules
|
||||
window.copyText = copyText;
|
||||
window.handleSubmit = handleSubmit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue