import { EventEmitter , Injectable } from '@angular/core' ; import { Card } from 'neuron-ipe-types' ; declare var acquireVsCodeApi ; @ Injectable ( ) export class ExtensionService { onAddCard : EventEmitter < Card > = new EventEmitter ( ) ; private vscode = acquireVsCodeApi ( ) ; constructor ( ) { window . addEventListener ( 'message' , event => { const message = event . data ; if ( message . command === 'add-card' ) { this . onAddCard . next ( message . card ) ; } } ) ; } param index moveCardUp ( index ) { this . vscode . postMessage ( { command : 'moveCardUp' , index : index } ) ; } param index moveCardDown ( index ) { this . vscode . postMessage ( { command : 'moveCardDown' , index : index } ) ; } param index deleteCard ( index ) { this . vscode . postMessage ( { command : 'deleteCard' , index : index } ) ; } param indexes deleteSelectedCards ( indexes ) { this . vscode . postMessage ( { command : 'deleteSelectedCards' , indexes : indexes } ) ; } param index param newTitle changeCardTitle ( index , newTitle ) { this . vscode . postMessage ( { command : 'changeTitle' , index : index , newTitle : newTitle } ) ; } param index param value collapseCode ( index , value ) { this . vscode . postMessage ( { command : 'collapseCode' , index : index , value : value } ) ; } param index param value collapseOutput ( index , value ) { this . vscode . postMessage ( { command : 'collapseOutput' , index : index , value : value } ) ; } param index param value collapseCard ( index , value ) { this . vscode . postMessage ( { command : 'collapseCard' , index : index , value : value } ) ; } param card addCustomCard ( card ) { this . vscode . postMessage ( { command : 'addCustomCard' , card : card } ) ; } param index param newCard editCustomCard ( index , newCard ) { this . vscode . postMessage ( { command : 'editCustomCard' , index : index , card : newCard } ) ; } param indexes jupyterExport ( indexes ) { this . vscode . postMessage ( { command : 'jupyterExport' , indexes : indexes } ) ; } param index openInBrowser ( index ) { this . vscode . postMessage ( { command : 'openInBrowser' , index : index } ) ; } /**
     * Notify the backend that the user has pressed
     * the undo button on the snackbar.
     */ undoClicked ( ) { this . vscode . postMessage ( { command : 'undoClicked' } ) ; } param pdf savePdf ( pdf ) { this . vscode . postMessage ( { command : 'savePdf' , pdf : pdf } ) ; } }