2度保存できない問題を解消
This commit is contained in:
parent
4a7160e97e
commit
5e4d7943ec
@ -89,6 +89,9 @@ export function getWebviewContent(imageSrc: string): string {
|
|||||||
let markColor = colorPicker.value;
|
let markColor = colorPicker.value;
|
||||||
let markLineWidth = parseInt(lineWidthSelect.value, 10);
|
let markLineWidth = parseInt(lineWidthSelect.value, 10);
|
||||||
|
|
||||||
|
// VS Code API を一度だけ取得
|
||||||
|
const vscode = window.acquireVsCodeApi ? window.acquireVsCodeApi() : null;
|
||||||
|
|
||||||
// UIイベント
|
// UIイベント
|
||||||
moveBtn.onclick = () => setMode('move');
|
moveBtn.onclick = () => setMode('move');
|
||||||
selectBtn.onclick = () => setMode('select');
|
selectBtn.onclick = () => setMode('select');
|
||||||
@ -118,6 +121,7 @@ export function getWebviewContent(imageSrc: string): string {
|
|||||||
draw();
|
draw();
|
||||||
};
|
};
|
||||||
saveBtn.onclick = () => {
|
saveBtn.onclick = () => {
|
||||||
|
console.log('Save button onclick fired!');
|
||||||
// 元画像サイズのオフスクリーンcanvasで保存
|
// 元画像サイズのオフスクリーンcanvasで保存
|
||||||
const offCanvas = document.createElement('canvas');
|
const offCanvas = document.createElement('canvas');
|
||||||
offCanvas.width = img.width;
|
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);
|
drawEllipseRaw(offCtx, mark.x1, mark.y1, mark.x2, mark.y2, mark.color, mark.lineWidth);
|
||||||
}
|
}
|
||||||
const dataUrl = offCanvas.toDataURL('image/png');
|
const dataUrl = offCanvas.toDataURL('image/png');
|
||||||
if (window.acquireVsCodeApi) {
|
console.log('Data URL created, checking VSCode API...');
|
||||||
const vscode = window.acquireVsCodeApi();
|
if (vscode) {
|
||||||
|
console.log('VSCode API available, sending message...');
|
||||||
vscode.postMessage({ type: 'save-image', dataUrl });
|
vscode.postMessage({ type: 'save-image', dataUrl });
|
||||||
|
console.log('Message sent to extension');
|
||||||
|
} else {
|
||||||
|
console.log('VSCode API not available!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user