From 5e4d7943ecd86dde73f789ce61e897d4d05c0cfd Mon Sep 17 00:00:00 2001 From: "ry.yamafuji" Date: Tue, 10 Jun 2025 02:59:26 +0900 Subject: [PATCH] =?UTF-8?q?2=E5=BA=A6=E4=BF=9D=E5=AD=98=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/webviewContent.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/webviewContent.ts b/src/webviewContent.ts index a1e7fcb..0bafee7 100644 --- a/src/webviewContent.ts +++ b/src/webviewContent.ts @@ -89,6 +89,9 @@ export function getWebviewContent(imageSrc: string): string { let markColor = colorPicker.value; let markLineWidth = parseInt(lineWidthSelect.value, 10); + // VS Code API を一度だけ取得 + const vscode = window.acquireVsCodeApi ? window.acquireVsCodeApi() : null; + // UIイベント moveBtn.onclick = () => setMode('move'); selectBtn.onclick = () => setMode('select'); @@ -118,6 +121,7 @@ export function getWebviewContent(imageSrc: string): string { draw(); }; saveBtn.onclick = () => { + console.log('Save button onclick fired!'); // 元画像サイズのオフスクリーンcanvasで保存 const offCanvas = document.createElement('canvas'); offCanvas.width = img.width; @@ -130,9 +134,13 @@ export function getWebviewContent(imageSrc: string): string { drawEllipseRaw(offCtx, mark.x1, mark.y1, mark.x2, mark.y2, mark.color, mark.lineWidth); } const dataUrl = offCanvas.toDataURL('image/png'); - if (window.acquireVsCodeApi) { - const vscode = window.acquireVsCodeApi(); + console.log('Data URL created, checking VSCode API...'); + if (vscode) { + console.log('VSCode API available, sending message...'); vscode.postMessage({ type: 'save-image', dataUrl }); + console.log('Message sent to extension'); + } else { + console.log('VSCode API not available!'); } };