aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index f07c644b7..c9c006aa8 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -16,12 +16,10 @@ export class Utils {
public static GenerateGuid(): string {
return v4()
- // return new Buffer(v4()).toString("hex").substr(0, 24);
}
public static GenerateDeterministicGuid(seed: string): string {
return v5(seed, v5.URL)
- // return new Buffer(v5(seed, v5.URL)).toString("hex").substr(0, 24);
}
public static GetScreenTransform(ele: HTMLElement): { scale: number, translateX: number, translateY: number } {
@@ -33,6 +31,18 @@ export class Utils {
return { scale, translateX, translateY };
}
+ public static CopyText(text: string) {
+ var textArea = document.createElement("textarea");
+ textArea.value = text;
+ document.body.appendChild(textArea);
+ textArea.focus();
+ textArea.select();
+
+ try { document.execCommand('copy'); } catch (err) { }
+
+ document.body.removeChild(textArea);
+ }
+
public static Emit<T>(socket: Socket | SocketIOClient.Socket, message: Message<T>, args: T) {
socket.emit(message.Message, args);
}