feat: copy output easily. also build fixes.
This commit is contained in:
@@ -92,6 +92,31 @@
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.output-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.output-toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.output-copy-button {
|
||||
font-size: 11px;
|
||||
padding: 3px 10px;
|
||||
background-color: var(--vscode-button-secondaryBackground);
|
||||
color: var(--vscode-button-secondaryForeground);
|
||||
border: 1px solid var(--vscode-panel-border);
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.output-copy-button:hover {
|
||||
background-color: var(--vscode-list-hoverBackground);
|
||||
}
|
||||
|
||||
.output-item {
|
||||
background-color: var(--vscode-sideBar-background);
|
||||
border-radius: 4px;
|
||||
|
||||
@@ -250,6 +250,35 @@ export const Panel: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleCopyOutput = async () => {
|
||||
if (panelOutputEntries.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const outputText = panelOutputEntries.map((entry) => entry.message).join('\n\n');
|
||||
|
||||
if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
||||
await navigator.clipboard.writeText(outputText);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof document === 'undefined' || typeof document.createElement !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = outputText;
|
||||
textArea.setAttribute('readonly', '');
|
||||
textArea.style.position = 'absolute';
|
||||
textArea.style.left = '-9999px';
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
if (typeof document.execCommand === 'function') {
|
||||
document.execCommand('copy');
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
};
|
||||
|
||||
const renderTaskRow = (task: TaskProgress, isChild = false) => (
|
||||
<div key={task.taskId} className={`task-item status-${task.status} ${isChild ? 'task-child-row' : ''}`.trim()}>
|
||||
<div className="task-status">
|
||||
@@ -387,12 +416,25 @@ export const Panel: React.FC = () => {
|
||||
panelOutputEntries.length === 0 ? (
|
||||
<div className="panel-empty">{t('panel.noOutput')}</div>
|
||||
) : (
|
||||
<div className="output-list">
|
||||
{panelOutputEntries.map((entry) => (
|
||||
<div key={entry.id} className={`output-item output-${entry.kind}`}>
|
||||
{entry.message}
|
||||
</div>
|
||||
))}
|
||||
<div className="output-content">
|
||||
<div className="output-toolbar">
|
||||
<button
|
||||
type="button"
|
||||
className="output-copy-button"
|
||||
onClick={() => {
|
||||
void handleCopyOutput();
|
||||
}}
|
||||
>
|
||||
{t('panel.copyOutput')}
|
||||
</button>
|
||||
</div>
|
||||
<div className="output-list">
|
||||
{panelOutputEntries.map((entry) => (
|
||||
<div key={entry.id} className={`output-item output-${entry.kind}`}>
|
||||
{entry.message}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user