mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Copy clipboard command in ADS (html/plain text supported) (#13527)
* draft commit * few changes * Changes to copy query with results in plain and html formatting * undo changes * undo unintended change * remove comments * Addressed comments * Some clean up Co-authored-by: Monica Gupta <mogupt@microsoft.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { ClipboardData, IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; // {{SQL CARBON EDIT}}
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { $ } from 'vs/base/browser/dom';
|
||||
|
||||
@@ -13,6 +13,11 @@ export class BrowserClipboardService implements IClipboardService {
|
||||
|
||||
private readonly mapTextToType = new Map<string, string>(); // unsupported in web (only in-memory)
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
async write(data: ClipboardData, type?: string): Promise<void> {
|
||||
throw new Error('Not Implemented');
|
||||
}
|
||||
|
||||
async writeText(text: string, type?: string): Promise<void> {
|
||||
|
||||
// With type: only in-memory is supported
|
||||
|
||||
@@ -8,9 +8,21 @@ import { URI } from 'vs/base/common/uri';
|
||||
|
||||
export const IClipboardService = createDecorator<IClipboardService>('clipboardService');
|
||||
|
||||
// Added type https://www.electronjs.org/docs/api/clipboard#clipboardwritedata-type
|
||||
export interface ClipboardData { // {{SQL CARBON EDIT}}
|
||||
text?: string;
|
||||
html?: string;
|
||||
rtf?: string;
|
||||
bookmark?: string;
|
||||
}
|
||||
|
||||
export interface IClipboardService {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
/**
|
||||
* Writes data to the system clipboard.
|
||||
*/
|
||||
write(data: ClipboardData, type?: string): Promise<void>; // {{SQL CARBON EDIT}}
|
||||
|
||||
/**
|
||||
* Writes text to the system clipboard.
|
||||
|
||||
@@ -93,6 +93,7 @@ export interface ICommonElectronService {
|
||||
writeClipboardText(text: string, type?: 'selection' | 'clipboard'): Promise<void>;
|
||||
readClipboardFindText(): Promise<string>;
|
||||
writeClipboardFindText(text: string): Promise<void>;
|
||||
writeClipboardData(data: any, type?: 'selection' | 'clipboard'): Promise<void>; // {{SQL CARBON EDIT}}
|
||||
writeClipboardBuffer(format: string, buffer: Uint8Array, type?: 'selection' | 'clipboard'): Promise<void>;
|
||||
readClipboardBuffer(format: string): Promise<Uint8Array>;
|
||||
hasClipboard(format: string, type?: 'selection' | 'clipboard'): Promise<boolean>;
|
||||
|
||||
@@ -369,6 +369,11 @@ export class ElectronMainService implements IElectronMainService {
|
||||
return clipboard.writeText(text, type);
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
async writeClipboardData(windowId: number | undefined, data: any, type?: 'selection' | 'clipboard'): Promise<void> {
|
||||
return clipboard.write(data, type);
|
||||
}
|
||||
|
||||
async readClipboardFindText(windowId: number | undefined,): Promise<string> {
|
||||
return clipboard.readFindText();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { ClipboardData, IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; // {{SQL CARBON EDIT}}
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
@@ -20,6 +20,11 @@ export class NativeClipboardService implements IClipboardService {
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
) { }
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
async write(data: ClipboardData, type?: 'selection' | 'clipboard'): Promise<void> {
|
||||
return this.electronService.writeClipboardData(data, type);
|
||||
}
|
||||
|
||||
async writeText(text: string, type?: 'selection' | 'clipboard'): Promise<void> {
|
||||
return this.electronService.writeClipboardText(text, type);
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ export class TestElectronService implements IElectronService {
|
||||
async toggleDevTools(): Promise<void> { }
|
||||
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
|
||||
async readClipboardText(type?: 'selection' | 'clipboard' | undefined): Promise<string> { return ''; }
|
||||
async writeClipboardData(data: any, type?: 'selection' | 'clipboard' | undefined): Promise<void> { } // {{SQL CARBON EDIT}}
|
||||
async writeClipboardText(text: string, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
|
||||
async readClipboardFindText(): Promise<string> { return ''; }
|
||||
async writeClipboardFindText(text: string): Promise<void> { }
|
||||
|
||||
Reference in New Issue
Block a user