move openImage logic to command

This commit is contained in:
notoriousmango
2024-11-27 17:03:33 +09:00
parent 0b243279cc
commit 0715a50f63
2 changed files with 3 additions and 16 deletions
@@ -14,9 +14,9 @@ export class OpenImageCommand implements Command {
private readonly _webviewManager: MarkdownPreviewManager,
) { }
public execute(args: { resource: string, imageSource: string }) {
public execute(args: { resource: string; imageSource: string }) {
const source = vscode.Uri.parse(args.resource);
const { fsPath } = vscode.Uri.parse(args.imageSource);
this._webviewManager.findPreview(source)?.openImage(fsPath);
const imageSource = vscode.Uri.file(vscode.Uri.parse(args.imageSource).path);
vscode.commands.executeCommand('vscode.open', imageSource, this._webviewManager.findPreview(source));
}
}
@@ -443,7 +443,6 @@ export interface IManagedMarkdownPreview {
readonly onDidChangeViewState: vscode.Event<vscode.WebviewPanelOnDidChangeViewStateEvent>;
copyImage(id: string): void;
openImage(imagePath: string): void;
dispose(): void;
refresh(): void;
updateConfiguration(): void;
@@ -525,12 +524,6 @@ export class StaticMarkdownPreview extends Disposable implements IManagedMarkdow
});
}
openImage(imagePath: string): void {
const uri = vscode.Uri.file(imagePath);
this._webviewPanel.reveal();
vscode.commands.executeCommand('vscode.open', uri);
}
private readonly _onDispose = this._register(new vscode.EventEmitter<void>());
public readonly onDispose = this._onDispose.event;
@@ -686,12 +679,6 @@ export class DynamicMarkdownPreview extends Disposable implements IManagedMarkdo
});
}
openImage(imagePath: string): void {
const uri = vscode.Uri.file(imagePath);
this._webviewPanel.reveal();
vscode.commands.executeCommand('vscode.open', uri);
}
private readonly _onDisposeEmitter = this._register(new vscode.EventEmitter<void>());
public readonly onDispose = this._onDisposeEmitter.event;