mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)
* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 * disable strict null check
This commit is contained in:
49
src/vs/platform/clipboard/browser/clipboardService.ts
Normal file
49
src/vs/platform/clipboard/browser/clipboardService.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export class BrowserClipboardService implements IClipboardService {
|
||||
|
||||
_serviceBrand: ServiceIdentifier<IClipboardService>;
|
||||
|
||||
private _internalResourcesClipboard: URI[] | undefined;
|
||||
|
||||
async writeText(text: string, type?: string): Promise<void> {
|
||||
return navigator.clipboard.writeText(text);
|
||||
}
|
||||
|
||||
async readText(type?: string): Promise<string> {
|
||||
return navigator.clipboard.readText();
|
||||
}
|
||||
|
||||
readTextSync(): string | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
readFindText(): string {
|
||||
// @ts-ignore
|
||||
return undefined;
|
||||
}
|
||||
|
||||
writeFindText(text: string): void { }
|
||||
|
||||
writeResources(resources: URI[]): void {
|
||||
this._internalResourcesClipboard = resources;
|
||||
}
|
||||
|
||||
readResources(): URI[] {
|
||||
return this._internalResourcesClipboard || [];
|
||||
}
|
||||
|
||||
hasResources(): boolean {
|
||||
return this._internalResourcesClipboard !== undefined && this._internalResourcesClipboard.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IClipboardService, BrowserClipboardService, true);
|
||||
@@ -15,12 +15,14 @@ export interface IClipboardService {
|
||||
/**
|
||||
* Writes text to the system clipboard.
|
||||
*/
|
||||
writeText(text: string, type?: string): void;
|
||||
writeText(text: string, type?: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Reads the content of the clipboard in plain text
|
||||
*/
|
||||
readText(type?: string): string;
|
||||
readText(type?: string): Promise<string>;
|
||||
|
||||
readTextSync(): string | undefined;
|
||||
|
||||
/**
|
||||
* Reads text from the system find pasteboard.
|
||||
|
||||
@@ -14,14 +14,18 @@ export class ClipboardService implements IClipboardService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
writeText(text: string, type?: string): void {
|
||||
async writeText(text: string, type?: 'selection' | 'clipboard'): Promise<void> {
|
||||
clipboard.writeText(text, type);
|
||||
}
|
||||
|
||||
readText(type?: string): string {
|
||||
async readText(type?: 'selection' | 'clipboard'): Promise<string> {
|
||||
return clipboard.readText(type);
|
||||
}
|
||||
|
||||
readTextSync(): string {
|
||||
return clipboard.readText();
|
||||
}
|
||||
|
||||
readFindText(): string {
|
||||
if (isMacintosh) {
|
||||
return clipboard.readFindText();
|
||||
|
||||
Reference in New Issue
Block a user