import { Injectable } from '@angular/core' ; import { clipboard , NativeImage } from 'electron' ; @ Injectable ( { providedIn : 'root' } ) export class ClipboardManager { public containsImage ( ) { const availableFormats = clipboard . availableFormats ( 'clipboard' ) ; if ( availableFormats . includes ( 'image/png' ) || availableFormats . includes ( 'image/jpeg' ) ) { return true ; } return false ; } public containsText ( ) { const text = clipboard . readText ( ) ; if ( text ) { return true ; } return false ; } public writeText ( text ) { clipboard . writeText ( text ) ; } public readText ( ) { return clipboard . readText ( ) ; } public readImage ( ) { const clipboardImage = clipboard . readImage ( ) ; const blob = new Blob ( [ clipboardImage . toJPEG ( 80 ) ] , { type : 'image/jpeg' } ) ; return blob ; } }