mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 17:22:55 -05:00
76
src/sql/platform/clipboard/browser/clipboardService.ts
Normal file
76
src/sql/platform/clipboard/browser/clipboardService.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService';
|
||||
import { IClipboardService as vsIClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export class BrowserClipboardService implements IClipboardService {
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(
|
||||
@vsIClipboardService private _vsClipboardService: vsIClipboardService,
|
||||
@INotificationService private _notificationService: INotificationService
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Writes the input image as a dataurl to the clipbaord
|
||||
*/
|
||||
async writeImageDataUrl(data: string): Promise<void> {
|
||||
// not implemented until web standards catch up
|
||||
this._notificationService.info(localize('imageCopyingNotSupported', "Copying images is not supported"));
|
||||
}
|
||||
|
||||
writeText(text: string): Promise<void> {
|
||||
return this._vsClipboardService.writeText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the content of the clipboard in plain text
|
||||
*/
|
||||
readText(): Promise<string> {
|
||||
return this._vsClipboardService.readText();
|
||||
}
|
||||
/**
|
||||
* Reads text from the system find pasteboard.
|
||||
*/
|
||||
readFindText(): string {
|
||||
return this._vsClipboardService.readFindText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes text to the system find pasteboard.
|
||||
*/
|
||||
writeFindText(text: string): void {
|
||||
this._vsClipboardService.writeFindText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes resources to the system clipboard.
|
||||
*/
|
||||
writeResources(resources: URI[]): void {
|
||||
this._vsClipboardService.writeResources(resources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads resources from the system clipboard.
|
||||
*/
|
||||
readResources(): URI[] {
|
||||
return this._vsClipboardService.readResources();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if resources are copied to the clipboard.
|
||||
*/
|
||||
hasResources(): boolean {
|
||||
return this._vsClipboardService.hasResources();
|
||||
}
|
||||
|
||||
readTextSync(): string | undefined {
|
||||
return this._vsClipboardService.readTextSync();
|
||||
}
|
||||
}
|
||||
@@ -13,5 +13,5 @@ export interface IClipboardService extends vsIClipboardService {
|
||||
/**
|
||||
* Writes the input image as a dataurl to the clipbaord
|
||||
*/
|
||||
writeImageDataUrl(data: string): void;
|
||||
}
|
||||
writeImageDataUrl(data: string): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -3,72 +3,26 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IClipboardService as vsIClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { BrowserClipboardService } from 'sql/platform/clipboard/browser/clipboardService';
|
||||
import { clipboard, nativeImage } from 'electron';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export class ClipboardService implements IClipboardService {
|
||||
export class ClipboardService extends BrowserClipboardService {
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(
|
||||
@vsIClipboardService private _vsClipboardService: vsIClipboardService
|
||||
) { }
|
||||
@vsIClipboardService _vsClipboardService: vsIClipboardService,
|
||||
@INotificationService _notificationService: INotificationService
|
||||
) {
|
||||
super(_vsClipboardService, _notificationService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the input image as a dataurl to the clipbaord
|
||||
*/
|
||||
writeImageDataUrl(data: string): void {
|
||||
async writeImageDataUrl(data: string): Promise<void> {
|
||||
let image = nativeImage.createFromDataURL(data);
|
||||
clipboard.writeImage(image);
|
||||
}
|
||||
|
||||
writeText(text: string): Promise<void> {
|
||||
return this._vsClipboardService.writeText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the content of the clipboard in plain text
|
||||
*/
|
||||
readText(): Promise<string> {
|
||||
return this._vsClipboardService.readText();
|
||||
}
|
||||
/**
|
||||
* Reads text from the system find pasteboard.
|
||||
*/
|
||||
readFindText(): string {
|
||||
return this._vsClipboardService.readFindText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes text to the system find pasteboard.
|
||||
*/
|
||||
writeFindText(text: string): void {
|
||||
this._vsClipboardService.writeFindText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes resources to the system clipboard.
|
||||
*/
|
||||
writeResources(resources: URI[]): void {
|
||||
this._vsClipboardService.writeResources(resources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads resources from the system clipboard.
|
||||
*/
|
||||
readResources(): URI[] {
|
||||
return this._vsClipboardService.readResources();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if resources are copied to the clipboard.
|
||||
*/
|
||||
hasResources(): boolean {
|
||||
return this._vsClipboardService.hasResources();
|
||||
}
|
||||
|
||||
readTextSync(): string | undefined {
|
||||
return this._vsClipboardService.readTextSync();
|
||||
return clipboard.writeImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user