mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Merge pull request #635 from tkaaad97/fix-custom-editor-sample-postMessage
Fix postMessage arguments to efficiently send binary data to webview
This commit is contained in:
@ -240,16 +240,14 @@
|
||||
return;
|
||||
} else {
|
||||
// Load the initial image into the canvas.
|
||||
const data = new Uint8Array(body.value.data);
|
||||
await editor.reset(data);
|
||||
await editor.reset(body.value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
case 'update':
|
||||
{
|
||||
const data = body.content ? new Uint8Array(body.content.data) : undefined;
|
||||
const strokes = body.edits.map(edit => new Stroke(edit.color, edit.stroke));
|
||||
await editor.reset(data, strokes)
|
||||
await editor.reset(body.content, strokes)
|
||||
return;
|
||||
}
|
||||
case 'getFileData':
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
"url": "https://github.com/Microsoft/vscode-extension-samples"
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.52.0"
|
||||
"vscode": "^1.65.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
@ -59,7 +59,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.0",
|
||||
"@types/vscode": "^1.52.0",
|
||||
"@types/vscode": "^1.65.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.19.0",
|
||||
"@typescript-eslint/parser": "^5.19.0",
|
||||
"eslint": "^8.13.0",
|
||||
|
||||
@ -34,7 +34,7 @@ class PawDrawDocument extends Disposable implements vscode.CustomDocument {
|
||||
if (uri.scheme === 'untitled') {
|
||||
return new Uint8Array();
|
||||
}
|
||||
return vscode.workspace.fs.readFile(uri);
|
||||
return new Uint8Array(await vscode.workspace.fs.readFile(uri));
|
||||
}
|
||||
|
||||
private readonly _uri: vscode.Uri;
|
||||
|
||||
Reference in New Issue
Block a user