generated from tomchen/example-typescript-package
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { URL } from "url"; | ||
import { ClipboardType, IClipboard } from "../clipboard_interface"; | ||
|
||
export abstract class BaseClipboard implements IClipboard { | ||
abstract getImage(imagePath: string): Promise<string>; | ||
abstract getTextPlain(): Promise<string>; | ||
abstract getTextHtml(): Promise<string>; | ||
abstract copyImage(imageFile: URL): Promise<boolean>; | ||
abstract copyTextPlain(textFile: URL): Promise<boolean>; | ||
abstract copyTextHtml(htmlFile: URL): Promise<boolean>; | ||
abstract getContentType(): Promise<Set<ClipboardType> | ClipboardType>; | ||
|
||
abstract onDetectType(types: string[]): Set<ClipboardType>; | ||
|
||
detectType(types: string[]): Set<ClipboardType> | ClipboardType { | ||
if (!types) { | ||
return ClipboardType.Unknown; | ||
} | ||
|
||
const detectedTypes = this.onDetectType(types); | ||
if (detectedTypes.size == 1) { | ||
return detectedTypes.values().next().value; | ||
} else if (detectedTypes.size > 1) { | ||
return detectedTypes; | ||
} | ||
return ClipboardType.Unknown; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.